ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
596 stars 245 forks source link

sigset_t undeclared #140

Open ajmilford opened 7 years ago

ajmilford commented 7 years ago

New to ceedling

Added first module and all worked fine. Now added second module and when I try rake test:all I get a compilation error in the second module:

Test 'test_measure.c'

Generating runner for test_measure.c... Compiling test_measure_runner.c... In file included from /usr/include/setjmp.h:10:0, from C:/Project_890/300_Software/301_firmware/LiIon/vendor/ceed ling/vendor/unity/src/unity_internals.h:14, from C:/Project_890/300_Software/301_firmware/LiIon/vendor/ceed ling/vendor/unity/src/unity.h:16, from build/test/runners/test_measure_runner.c:22: /usr/include/machine/setjmp.h:380:66: error: 'sigset_t' undeclared here (not in a function) typedef _JBTYPE sigjmp_buf[_JBLEN+1+((sizeof (_JBTYPE) + sizeof (sigset_t) - 1)

                                                              ^

ERROR: Shell command failed.

Shell executed command: 'gcc.exe -I"test" -I"test/support" -I"src" -I"src/Common" -I"src/comms" -I"src/h al" -I"src/USB_CDC_API" -I"src/USB_Common" -I"src/USB_HID_API" -I"C:/Project_890 /300_Software/301_firmware/LiIon/vendor/ceedling/vendor/unity/src" -I"C:/Project _890/300_Software/301_firmware/LiIon/vendor/ceedling/vendor/cmock/src" -I"build/ test/mocks" -DTEST -DGNU_COMPILER -g -c "build/test/runners/test_measure_runner. c" -o "build/test/out/test_measure_runner.o"' And exited with status: [1].

rake aborted!

What have I done wrong?

mvandervoord commented 7 years ago

That's not an error I've seen before. I'm assuming your first module had a working test or two, though, so that suggests it is likely something in this test module specifically. Can you post your test here? If you're not comfortable doing that, can you send it to me directly? Or, even less revealing, can you just send the top of it (including all your includes, etc, but before the tests themselves)?

ajmilford commented 7 years ago

Attached the three test files and the three modules they are to test (all renamed .txt to allow dag and drop upload).

I found if I do rake test:measure it still gives the same compilation error

Thanks

test_audio.c.txt test_measure.c.txt test_signal.c.txt audio.c.txt measure.c.txt signal.c.txt

mvandervoord commented 7 years ago

But the other two modules work okay individually?

ajmilford commented 7 years ago

I thought audio was working, and it was before I added the two new tests But then I did rake clean and now audio does not work either, it now gives the same compilation error!

mvandervoord commented 7 years ago

It's interesting that the test for signal is the one that works. Your test_signal.c file includes "signal.h", which might be confused with . The system file is used by , which might be important because is used by Unity to handle failures.

Do your other modules start working if you start including in them?

ajmilford commented 7 years ago

That's it - many thanks!

Renamed my project signal.h to something else and now all tests work again! Clearly it was finding my local signal.h in preference to the system !

So I guess I need to make sure any source/header files in my project aren't the same as any system files - or can it be configured so that

include <...>

looks in the system folders whereas

include "..."

looks in my project folders? I seem to remember vaguely from many years ago some C compilers doing that but I don't know if gcc can do that?

Thanks anyway for your pointers.

mvandervoord commented 7 years ago

I'm not sure. I honestly thought most C compilers (gcc included) would look locally first for "" style includes and at the system folders first for <> style includes... but that doesn't appear to be the case from your example. I'll do a bit of poking around and see if there is something we could be calling better to make that happen.

mvandervoord commented 7 years ago

Looking at the docs for gcc (I think other compilers will vary on this topic), The "" includes will search the local directory and then the system directories. The <> will jump straight to system directories.

Sounds great, right?

BUT, if you add -I includes (as Ceedling does), to look in more directories, it gets a bit more tricky. For "" those directories are checked after the local directory and before the system. For <> They are checked before the system, which I believe is the problem we are seeing.

I think the solution is to stop Ceedling from including the -I calls when it's angle brackets. I think the side effect of this, though, would be that CMock would no longer be able to mock system files.

Anyone have other ideas?