Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to add -std=c99 flag to make command but I have no idea how to do it. Where is related file located?

@Andrejs Cainikovs But I have not found related file or files yet.

share|improve this question
    
Makefile usually is placed in project top folder. However, if the project has multiple source file folders, there might be more than one Makefile. Find them: find -name Makefile. –  Andrejs Cainikovs Jun 7 '12 at 7:34
    
@Andrejs Cainikovs it returned nothing hrn@hrn-vaio:~$ find -name make hrn@hrn-vaio:~$ –  hrn Jun 7 '12 at 8:00
    
This is not the same command. –  Andrejs Cainikovs Jun 7 '12 at 8:05
    
Linux is case sensitive. –  david6 Jun 7 '12 at 8:51
    
@david6 I have done all possibilities even so I could not find anything –  hrn Jun 7 '12 at 9:05

1 Answer 1

up vote 1 down vote accepted

Assuming you already have a Makefile:

$ CFLAGS="-std=c99" make

Adding following to your Makefile will also work:

CFLAGS=-std=c99

Or, if using configure:

$ CFLAGS="-std=c99" ./configure
share|improve this answer
    
It did not work OUTPUT [code] hrn@hrn-vaio:~/c$ CFLAGS=-std=c99 hrn@hrn-vaio:~/c$ make hrn cc hrn.c -o hrn hrn.c: In function ‘main’: hrn.c:7:2: error: ‘for’ loop initial declarations are only allowed in C99 mode hrn.c:7:2: note: use option -std=c99 or -std=gnu99 to compile your code make: *** [hrn] Error 1 hrn@hrn-vaio:~/c$ –  hrn Jun 7 '12 at 7:36
    
Sure it will not work, since you have split original command into two parts, and make is not aware about CFLAGS anymore. Execute the whole command, as I have provided. –  Andrejs Cainikovs Jun 7 '12 at 7:39
    
same error hrn@hrn-vaio:~/c$ CFLAGS="-std=c99" make make: *** No targets specified and no makefile found. Stop. hrn@hrn-vaio:~/c$ make hrn cc hrn.c -o hrn hrn.c: In function ‘main’: hrn.c:7:2: error: ‘for’ loop initial declarations are only allowed in C99 mode hrn.c:7:2: note: use option -std=c99 or -std=gnu99 to compile your code make: *** [hrn] Error 1 hrn@hrn-vaio:~/c$ –  hrn Jun 7 '12 at 7:45
    
CFLAGS="-std=c99" make hrn –  Andrejs Cainikovs Jun 7 '12 at 8:05
    
Thank you, it worked! –  hrn Jun 7 '12 at 8:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.