This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Header compilation
- To: help-gcc at gnu dot org
- Subject: Re: Header compilation
- From: Ross Smith <ross dot s at ihug dot co dot nz>
- Date: Tue, 31 Aug 1999 10:23:58 +1300
- Newsgroups: gnu.gcc.help
- Organization: The Internet Group
- References: <u4Ay3.6649$914.473155@typ11.nn.bcandid.com>
- Xref: wodc7nx0 gnu.gcc.help:761
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