I get this error in a C header file in this line :
char * getFechaHora(time_t & tiempoPuro);
In a C source code file i am including the header file and giving the function an implementation
char * getFechaHora(time_t &tiempoPuro){...}
also in my header file i am including correctly the "time.h" library.
expected” This error occurs when something is missing from the code. Often this is created by a missing semicolon or closing parenthesis.
Error: expected ')' before ';' token in C Consider the given example, here I terminated the #define statement by the semicolon, which should not be terminated. How to fix? To fix this error, check the statement which should not be terminated and remove semicolons.
The " expected identifier before '(' token " error occurs because you are using -> operator to access a field of a struct and, instead of passing the field identifier, you are passing a '(' character. Here is the list of errors. av->(A. code) is bad syntax.
It means the syntax is invalid.
char * getFechaHora(time_t & tiempoPuro);
This is not C. C has no reference (&
).
In C, if char * getFechaHora, this is your function and the two (time_t & tiempoPuro) are arguments you should declare the function as:
char * getFechaHora(*type* time_t, *type* tiempoPuro);
else if the second is a variable, declare as
char * getFechaHora(time_t *tiempoPuro);
The problem is your use of the &
symbol. Passing by reference in that way is not supported in C. To accomplish this in C, you need to pass in a pointer to the variable like so:
char * getFechaHora(time_t * tiempoPuro);
Technically, you are still passing by value (passing the value of the pointer), but it will accomplish the same thing (modifying the value pointed to by the tiempoPuro
variable local to the getFechaHora
function will change the value of the variable local to the function it was called from).
Reference: Pass by Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With