I have tried and googled everything, but I cannot seem to fix these mysterious errors. Within my helpers.c file, it is saying that I haven't used any of the parameters although I've used all of them.

Below are the errors I'm getting:

helpers.c:8:21: error: unused parameter 'fraction' [-Werror,-Wunused-parameter] int duration(string fraction) ^ helpers.c:11:1: error: control reaches end of non-void function [-Werror,-Wreturn-type] } ^

helpers.c:14:22: error: unused parameter 'note' [-Werror,-Wunused-parameter] int frequency(string note) ^

helpers.c:17:1: error: control reaches end of non-void function [-Werror,-Wreturn-type] } ^

helpers.c:20:21: error: unused parameter 's' [-Werror,-Wunused-parameter] bool is_rest(string s) ^

helpers.c:23:1: error: control reaches end of non-void function [-Werror,-Wreturn-type] } ^

6 errors generated.

Here is my code:

// Helper functions for music

#include <cs50.h>
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "helpers.h"

// Converts a fraction formatted as X/Y to eighths
int duration(string fraction)
    // convert string input to int
    int x = fraction[0] - '0';
    int y = fraction[2] - '0';
    // convert to integral number of eighths
    if (y == 8)
        return x;
    return (8 / y) * x;

// Calculates frequency (in Hz) of a note
int frequency(string note)
    // Parse string <note> //not quite sure on data types (chars or int?)
    int baseHz = 440; //A4's Hz
    char letter = note[0];

    if (strlen(note) < 3) //notes with # or b
        int octave = note[1] - '0';
    else //notes without # or b
        int octave = note[2] - '0';
    //find distance from octave 4
    int octave_dist = octive - 4; //power of 2 for octave adjustment
    //multiplier to adjust for octave
    int octave_adjust = pow(2, octave_dist); //not sure on types here??

    //find note distance from A
    float n = 2.0; //number of semitones between notes
    if (letter != 'B') //B will use default n = 2
        n = ('A' - letter) * 2;
    //multiplier to adjust for note
    float note_adjust = pow(2, n/12.0);

    //multiplier to adjust for # or b

    int Hz = round(baseHz * octave_adjust * note_adjust);
    return Hz;

// Determines whether a string represents a rest
bool is_rest(string s)
    //get_string return "" if user input is only a line ending
    if (strcmp(s, "") == 0)
        return true;
    return false;

I'm still working on my functions (step by step) as recommended by course instructions, but I can't even compile to see if anything I've done is correct.

I don't understand why I haven't "used the parameters" Another thing I can point out is that my errors are giving me the (seemingly) incorrect locations. Could this mean there is something wrong with the IDE/compiler/makefile?

I've been killing myself over this for days. Any help would be HUGELY appreciated. Thanks you in advance.

  • The "unused parameters" are easy - those are line numbers from the helpers.c in the ZIP file, each function contains only // TODO, but no return. Did you forget to save? Did you save under another name or in another directory?
    – Blauelf
    May 18, 2018 at 7:50
  • Nice find! Hmm I have the file saved in ~/workspace/pset3/music/ , so I'm not sure why it would be trying to use the zip file
    – aherzfeld
    May 18, 2018 at 7:53
  • I just saved again using "save as" - this solved the problem! It seems that using ctrl s wasn't working properly?
    – aherzfeld
    May 18, 2018 at 7:59

1 Answer 1


There are a few simple issues. First, octave is being declared and then redeclared, but, amusingly, that isn't the actual problem. The real problem is that they are being declared inside of code blocks attached to the if/else statements. That means that after the closing curly brace after each declaration, they go out of scope and cease to exist! You should declare octave before the if/else statements and then assign the value as a separate operation inside the if/else statements.

Next, there's the matter of a typo - octive vs. octave.

I compiled your code but couldn't duplicate the other errors. Are you sure this is the current file, or that you are saving the source code file before recompiling?

FYI, the "control may reach..." error is explained here:



Unused parameter errors are self-explanatory. It means that a parameter in the function's signature was never used inside the function. It's actually a warning, but the makefile and the IDE are set up to treat warnings as errors.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thank you so much Cliff! after following both your and blauelf's advice I was able to compile! This was actually my first time ever asking a question on stack exchange and this had been my nightmare for days. Thank you both for the successful fixes :D
    – aherzfeld
    May 18, 2018 at 8:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .