This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Symbol referencing error






I'm confused.....

*pToUpperC is decalred in a header file as:

char *pToUpperC()

and hence looks like a function. But the function body has not been defined
either in the syb2pv.h or syb2pv.c files.

I changed the above to:

char *pToUpperC(char *)

since pNote is declared as:

char *pNote

I also, declared *pToUpperC in my syb2pv.c file, but still get the error
message.

Was this what  I was meant to do?

Thanks

==================================

At 15.24 06/02/2002 (GMT +0000), kabir.patel@uk.andersen.com wrote:
>I have the following in my code:
>
>char *pToUpperC()
>
>and also...
>
>fprintf(stream,",%s", pToUpperC(pNote));

It seems strange to be a GCC related problem.
Are those in the same file (with the funcion before the fprintf) ?
If not, you should use them like this:

***** Solution A) All in one file:
************************************************

// main.c

char *pToUpperC(char *argument) {       // this defines the function
   ...
}

...

fprintf(stream,",%s", pToUpperC(pNote));        // this uses it

// end of main.c

***** Solution B) All in one file, with forward declaration
************************************************

// main.c

char *pToUpperC(char *argument);        // this declares the function

...

fprintf(stream,",%s", pToUpperC(pNote));        // this uses it

...

char *pToUpperC(char *argument) {       // this defines it
   ...
}

// end of main.c

***** Solution C) Two different files
************************************************

// file pToUpper.h
#ifndef pToUpper_h
#define pToUpper_h

char *pToUpperC(char *argument);        // this declares the function

#endif // pToUpper_h
// end of file pToUpper.h

// file pToUpper.c
char *pToUpperC(char *argument) {       // this defines the function
   ...
}
// end of file pToUpper.c

// main.c (where you call pToUpper() from)
#include "pToUpper.h"

...
fprintf(stream,",%s", pToUpperC(pNote));        // this uses the function
...

// end of main.c

*****************************************************
In cases A & B, compile with

gcc main.c -o main

In case C with

gcc main.c pToUpper.c -o main
*****************************************************

If all this sound silly, I'm sorry, but I couldn't think of anything else.

fwyzard








*******************Internet Email Confidentiality Footer*******************


Privileged/Confidential Information may be contained in this message.  If you
are not the addressee indicated in this message (or responsible for delivery of
the message to such person), you may not copy or deliver this message to anyone.
In such case, you should destroy this message and kindly notify the sender by
reply email. Please advise immediately if you or your employer does not consent
to Internet email for messages of this kind.  Opinions, conclusions and other
information in this message that do not relate to the official business of my
firm shall be understood as neither given nor endorsed by it.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]