stop gcc from showing warnings

how can I do that?

I have the following:

gcc -g -o optCompiler lex.yy.c ic.tab.c opt.c optFunctions.c -lfl


and it generates warning such as:

scanner:71: warning: incompatible implicit declaration of built-in function âstrcpyâ
scanner:180: warning: incompatible implicit declaration of built-in function âstrcpyâ


ic.y:1289: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1291: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1302: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1308: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1313: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1351: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1353: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1364: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1370: warning: passing argument 1 of âstrcatâ from incompatible pointer type
ic.y:1375: warning: passing argument 1 of âstrcatâ from incompatible pointer type
kuntilanakAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fridomCEO/ProgrammerCommented:
At first you should include the proper headers in  this case
#include <string.h>

Then you'll see that  tons of warning will "vanish"

Warning should give you an idea that you may do something wrong, discarding them without understanding is a very poor idea

Regards
Friedrich
0
kuntilanakAuthor Commented:
I already have #include <string.h> in every of my file that produces the warning above, but it is still the same
0
fridomCEO/ProgrammerCommented:
I'm sorry, but the warning implies otherwise.

Regards
Friedrich
0
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

fridomCEO/ProgrammerCommented:
What's the content of thy *.yy file?
Check how flex or the like should be written. The warnings show explicitly that string.h is not proper included
0
kuntilanakAuthor Commented:
when I tried to see what's on line 71 I did not see any strcpy.. this is weird
0
fridomCEO/ProgrammerCommented:
How about posting some code?

Regards
Friedrich
0
kuntilanakAuthor Commented:
here is the scanner code
%{
#include "ic.tab.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define	TIF		260
#define	TELSE	 	261
#define	TWHILE		262
#define	TFOR		263
#define	TRETURN	264
#define	TDEQUALS	265
#define	TEXTERN	266
#define	TVOID		267
#define	TID		268
#define	TINTCON	269
#define 	TCHARCON	270
#define	TSTRCON	271
#define	TCHAR		272
#define	TINT		273
#define	TNEQUALS	274
#define 	TLE		275
#define	TGE		276
#define 	TDAMP		277
#define 	TDPIPE		278
#define 	TNOT		279
/*	Global Variable Declarations*/
/*	For line number and for loop variable for Line Number calculation */
int linenumber=1;
%}
letter 	[a-zA-Z]
digit 		[0-9]
notvalid	[^"<"">"";""\[""\]""\{""\}""\(""\)""=""=="",""+""\-""*""/"]
charcon		"'"[a-zA-Z0-9]"'"|"'\\n'"|"'\\0'"|'%'|"' '"
invalidchar	"'''"|"'"[^a-zA-Z0-9|\\n|\\0|%| ]"'"
wspace		[ \t]
id 		{letter}+({letter}|{digit}|"_")*
intcon 		{digit}+
%%
{invalidchar}	{	printf("*** Illegal Character Constant. Lexical Scanner Error at line %d due to %s ***\n",linenumber,yytext);
			return 0;
		}
{charcon}	{
		yylval.integerConst = atoi(yytext) ;
		return TCHARCON; 
		}
{intcon} 	{ 
		yylval.integerConst = atoi(yytext) ;
		return TINTCON; 
		}
{wspace}
int		return TINT;
char		return TCHAR;
if 		return TIF;
else		return TELSE;
while		return TWHILE;
for		return TFOR;
return		return TRETURN;
void 		return TVOID;
extern		return TEXTERN;
"=="		return TDEQUALS;
"!="		return TNEQUALS;
"<="		return TLE;
">="		return TGE;
"&&"		return TDAMP;
"||"		return TDPIPE;
{id} 		{ strcpy(yylval.attributes.name,yytext); return TID;}
"!"		return TNOT;
"<"		return toascii('<');
">"		return toascii('>');
";"		return toascii(';');
"["		return toascii('[');
"]"		return toascii(']');
"("		return toascii('(');
")"		return toascii(')');
"{"		return toascii('{');
"}"		return toascii('}');
","		return toascii(',');
"+"		return toascii('+');		
"-"		return toascii('-');
"/"		return toascii('/');
"*"		return toascii('*');
"="		return toascii('=');	
"/*"        {
                  /* code segment used from the Flex manual */
                  int c,start;
                  start=linenumber;
 
                  for ( ; ; )
                      {
                      while ( (c = input()) != '*' && c != EOF ){
                              if( c == '\n' ) linenumber++;
                              else
                              ;
                              }
                               /* eat up text of comment */
 
 
		     if ( c == '*' )
                          {
                          while ( (c = input()) == '*' )
                              ;
                          if ( c == '/' )
                              break;    /* found the end */
                          }
 
                      if ( c == EOF )
                          {
                          printf( "*** Comment not closed before EOF *** Unclosed Comment Starts at line number %d \n",start);
                          break;
                          }
                      }
              }
"\""		{	int i=1,c1,c2,c3,start1;
			start1 = linenumber;
			for ( ; ; )
				{
				c1 = input();
				/*yytext[i]=c1;
				i++;*/
				
				while  ( 
						( 	
							(  c1 >= 'A' && c1 <= 'Z'  ) || ( c1>='0' && c1 <='9') || 
							( c1 >='a' && c1 <='z' ) || c1 =='%' || c1 == ' '  || c1 == '\\') &&
							c1 != EOF   && c1 != '"' && c1 != '\n'  
					)
				     
				{
				if ( c1 =='\\' ) 
				{
					c2 = '\\';
					c3 = input();
					if ( c3 != 'n')
					{
                          		printf( "*** Illegal Escape Character in the String due to \\%c *** at line number %d \n",c3,linenumber);
                          		return 0;
                          		}
                          		else
                          		{
                          		yytext[i]=c2;
					i++;
					yytext[i]=c3;
					i++;
					}
				}
				else
				{
                       		yytext[i]=c1;
				i++;
				}
				c1= input();
								
				}
				
												
				if ( c1 == EOF )
                          		{
                          		printf( "*** Quote not closed before EOF *** Quote Starts at line number %d \n",start1);
                          		break;
                          		} 
                          		
                          	else
                          	{
                          	if ( c1 == '"' ) 
                          		{
                          		yytext[i]=c1;
					i++;
					yytext[i]='\0';
					/* adding parser function here */
					strcpy(yylval.strConst,yytext) ;
                          		return TSTRCON;
                          		}
                          	else
                          		{
                          			if ( c1=='\n' )
                          			{
                          			printf("*** Illegal String. Lexical Scanner Error at line %d due to new line character ***\n",linenumber);
						return 0;
                          			}
                          			else
                          			{
                          			printf("*** Illegal String. Lexical Scanner Error at line %d due to `%c' ***\n",linenumber,c1);
						return 0;
						}				
                          		}
                          	}
                          	}
                          	
                         
                 }         
[\n]		linenumber++;
{notvalid} 	{	printf("*** Lexical Scanner Error at line %d. Character %s not recognised (or) Quote not closed. ***\n",linenumber,yytext);
			return 0;
		}
%%

Open in new window

0
Infinity08Commented:
How is yylval defined ? (YYSTYPE)
0
kuntilanakAuthor Commented:
yylval is just a build in flex function that we can use... I don't know if that answer's your question
0
Infinity08Commented:
>> I don't know if that answer's your question

I know what yylval is ;) I want to know how you (re-)defined it.
0
kuntilanakAuthor Commented:
what do you mean re-defined it? and where should we redefine it.. as far as I know we can just directly do a yylval. something and something has to exist in the union of the %union of the .y file
0
Infinity08Commented:
yylval is just an int value by default. You however use it as a struct, which means that you re-defined it.

>> the %union of the .y file

That's one way of re-defining yylval. Can you show that %union ?
0
kuntilanakAuthor Commented:
it's basically the same %union with my other threat that you're answering as well
0
Infinity08Commented:
Well, it's not the same, since you are using yylval.strConst which is not defined in your other thread's %union.

In any case, I assume that this is also related to the problem I pointed out in that other thread :

        http://www.experts-exchange.com/Programming/Languages/Parsers/Q_23874579.html#22880337
0
kuntilanakAuthor Commented:
believe it or not when I tried to run the code, it doesn't complain about not finding the strConst: here's my %union:

%union
      {
      ExprType etype;
      struct Attributes
            {
            char name[50];
            int intcharval;
            char strval[100];
            int actualvalue;
            int lvalue ;
            int dtype ;
            /* for symbol table*/
            int enumtype;
            struct ExprNode* node;
            } attributes;
            
      };


and my makefile:
build:	ic.tab.c 
	bison -v ic.y
	gcc -g -o compile lex.yy.c ic.tab.c -lfl
	
clean:	
	/bin/rm -f compile

Open in new window

0
Infinity08Commented:
So, is this problem resolved by what was discussed in :

        http://www.experts-exchange.com/Programming/Languages/Parsers/Q_23874579.html#22880337

Or are there further issues ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kuntilanakAuthor Commented:
these are two different codes, but I suppose as the other problem was solved I can close this one
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.