Friday, July 31, 2009

A precompiling problem (in C)...?

I have written fairly complex program. But I'm trying to set the number of elements of array by


eg #define DATABASE_SIZE 100


this is in my header.h file which is then included in the main file where it affects a variable (array) like this array[DATABASE_SIZE]





This works fine but when I change the database size number in header file it doesn't show in program (I have the maximum printed as sizeof array/sizeof array[0]...) unless I change something in main.c (for example to write something and then delete it.. only to change the file)





SO that leaves me thinking that compiler doesn't pre-compile files that haven't changed and logicaly this means that if I change only the header.h it doesn't affect main.c although it should (but the main.c didn't change) AND the updated header.h is not included in main.c (which leaves it with the old one...)





Is there a way how to go past it?? (I'm using Dev-C++...)

A precompiling problem (in C)...?
Does your compiler have a "make clean" or "build clean" option? Usually wen you compile with the "clean" option it recompiles everything, not just changed files.
Reply:Add a comment or a space or something to the other files, so the compiler sees that they've been "modified."


No comments:

Post a Comment