IDE not recompiling source on header change

Hi,
I am using Momentics 4.5.0 and Neutrino 6.4.0.

I have a QNX C++ project with about 10 .cpp and .h source files. I started the project 2 years ago, and only do minor source code maintenance these days, so I rarely make changes to header files.

I just noticed that changing a .h file does not cause the project or source file to recompile (either “compile selected” or “build all”). See compiler output below.

I don’t know if this is a recent configuration change or not (but I imagine I was a pretty unhappy camper 2 yrs ago if it was doing this then, too).

Any suggestions where to look?

Thanks,
Peter

The following is the result of:
a. making a simple change to state.h, and saving state.h
b. select state.cpp and select “compile selected”

C:\QNX640\host\win32\x86\usr\bin\make -k SRCS=state.cpp EXTRA_SUFFIXES=cpp state.o CLEAN=state.o --file=c:/temp/phays/QMakefile13256152730271883.tmp C:/QNX640/host/win32/x86/usr/bin/make -j 1 -Cx86 -fMakefile state.o make[1]: Entering directory `C:/Projects/psc/x86' C:/QNX640/host/win32/x86/usr/bin/make -j 1 -Co -fMakefile state.o make[2]: Entering directory `C:/Projects/psc/x86/o' make[2]: `state.o' is up to date. make[2]: Leaving directory `C:/Projects/psc/x86/o' C:/QNX640/host/win32/x86/usr/bin/make -j 1 -Co-g -fMakefile state.o make[2]: Entering directory `C:/Projects/psc/x86/o-g' make[2]: `state.o' is up to date. make[2]: Leaving directory `C:/Projects/psc/x86/o-g' make[1]: Leaving directory `C:/Projects/psc/x86'

Right click on the project and select “Check Dependencies On/Off” and set it to either “Check All Headers” or “Check User Headers Only” depending on what you want to do.

For some reason projects in Momentics have their default set to “Disable Checking” so changes to headers will not cause a re-compile. I usually set it to All just to be safe but it probably slows things down.

Thanks slougheed.

Good news. I never noticed that option there. It was off. (why isn’t it in the project settings???)

Bad news: If I set “check dependencies” to “all”, I get a different result, but the result is incomplete and inconsistent.

I created a new QNX C test project for an x86 target and modified the sample code. I made no changes to the default configuration, other than a.) select “Check Dependencies” = “All” and b.) de-selecting the debug variant.

I created 2 source files and 2 header files: test.c, test.h, test2.c, test2.h.
Each source file uses both header files.
Each header file contains 1 #define constant (TEST_DEF_1 and TEST_DEF_2).
Each source file uses both constants.
Each source file prints both values.

Making a change to either header should cause both object files to be rebuilt (test.o and test2.o).
If both .o files are rebuilt, then each .o file will contain code that prints the correct (updated) constant values.
If the IDE fails to rebuild a particular .o file, then that .o file will contain code that prints old values.

Results:

  1. Most of the time, if I edit test.h, only test2.o is rebuilt, and the output of the resulting executable includes test.o printing output that does not reflect the chage to test.h.
  2. However, a couple of times, while trying to make sure I was describing the steps correctly, I got both .o files to rebuild.
  3. Once, I got test.o to rebuild, but not test2.o.

In all cases, the console build output, and the dates of the .o and final executable file are always consistent with the printing results. I just find that the printed result is simpler to record.

I have attached a pdf including: the test code, the printed results, and the build output.

Anyone have any idea why i am getting such odd results for something as simple* as dependency checking?

Peter

Peter,

If you comment out the #Ifnotdef stuff in test.h and test2.h does it then work consistently?

It’s just a WAG, but I’m wondering if the compiler (Momentics) is ‘remembering between files’ that the values you are changing are already ‘defined’ when it compiles test2.c and so doesn’t bother to recompile test.c because everything in the ifdef is already defined from the prior compilation of test2.c and so it thinks there is nothing there in that header file (ie its being skipped) and thus no need to recompile.

Tim

Problem solved.
It is some bug in Momentics IDE 4.5.0 (QNX 6.4.0). Fixed in 4.6.0 (QNX 6.4.1). Don’t know if there is a workaround.

Test cases all work as expected in 4.6.0.

Thanks to all who helped.

Peter

found this in Foundry27: