c - gcc can't find define in header -


i'm using header called lib.h organize source code. header like:

#define tot_rep 10 #define tot_pat 10 #define time_rep 15 

the source file include header, when compile gcc i'm getting this:

error: ‘time_rep’ undeclared (first use in function) 

so tried compile gcc -e -dm , got this:

... #define sigusr2 12 #define time_rep 15 #define ____mbstate_t_defined 1 #define __sigrtmin 32 ... 

i tried gcc -e , in outuput found macro replaced value.

what can solve this?

edit: code time_rep used this:

while((!ending|| *(shmaddress+0)!=0)&& quitsignal==0){        totfolder=0;       buf=(char*)calloc(2,sizeof(char));       patientstring=(char*)calloc(2,sizeof(char));        sleep(time_rep);        while(read(fd,buf,sizeof(char))>0){          /*read file , data*/       }    } 

edit 2: tried rename lib.h , seems work can't understand why if gcc -e -dm found macro can't compile code.

anyway answer woodrow barlow:

i have lib.h , rep.c rep.c include lib.h , other headers:

#include <stdio.h> #include <stdlib.h> #include <sys/shm.h> #include <unistd.h> #include <string.h> #include "readerwriter.h" #include "lib.h" 

to compile use gcc rep.c -o rep -wall -pedantic


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -