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]

Re: Header compilation


nobody wrote:
> 
> I'm a bit of a newbie to gcc and c in general.  I declared a few variables
> in a .h file then I #include that into two c files.  lexvars.h is the header
> file.  This is what gcc has to say:
> 
> C:\Compiler\lyass1>gcc y.tab.c lexvars.h lex.yy.c libfl.a -o first

Don't put the header file in the compile command.
C:\Compiler\lyass1>gcc y.tab.c lex.yy.c libfl.a -o first

> unsigned clausecount = 0;
> fprintf("Clause count: %d", clausecount);

fprintf() expects to get a file handle as its first argument. If you
meant to write to a file, you first need to open it with fopen() and put
the resulting pointer before the string in fprintf(). If (as I suspect
is more likely) you meant to write to standard output (i.e. the DOS
prompt), you want printf(), not fprintf().

Also, you have the wrong format specifier: "%d" is for signed integers,
not unsigned ones. You need to either change "%d" to "%u", or make
clausecount an int instead of an unsigned.

--
Ross Smith <ross.s@ihug.co.nz> The Internet Group, Auckland, New Zealand
========================================================================
  "There are many technical details that make Linux attractive to the
  sort of people to whom technical details are attractive."   -- Suck


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