Skip to content

Test in both C and C++#58

Merged
bvisness merged 8 commits intomasterfrom
handmade-test
Apr 7, 2017
Merged

Test in both C and C++#58
bvisness merged 8 commits intomasterfrom
handmade-test

Conversation

@bvisness
Copy link
Copy Markdown
Member

@bvisness bvisness commented Apr 3, 2017

An attempt to fix #57 forever. I wrote a small, custom unit test setup that meets our needs without extraneous features.

This should build in both C and C++ modes with both clang and gcc/g++. But we shall see if Travis behaves...

@bvisness bvisness self-assigned this Apr 3, 2017
@bvisness
Copy link
Copy Markdown
Member Author

bvisness commented Apr 3, 2017

@DanielGibson Well, this is annoying. I'm explicitly using -std=c99 but for some reason Travis is still not seeing sinf, cosf, etc., which are supposed be standard in c99. Do you know the "right" way to fix this?

(see https://travis-ci.org/StrangeZak/Handmade-Math/jobs/217910297)

@DanielGibson
Copy link
Copy Markdown
Contributor

looks like it can't find the functions at link time, try adding -lm :)

@DanielGibson
Copy link
Copy Markdown
Contributor

Also, not sure what -isystem is supposed to do here, but in the GCC manpage it sounds like it needs an additional argument (directory to headers?), but either way it doesn't sound like it should be needed there

@bvisness
Copy link
Copy Markdown
Member Author

bvisness commented Apr 3, 2017

-isystem was an attempt to mimic the includes that were being used with our old test framework. Suffice to say, it didn't work and I can get rid of it.

@bvisness
Copy link
Copy Markdown
Member Author

bvisness commented Apr 3, 2017

@DanielGibson Well, clang is happy now but gcc is not. I'm not sure why, since the -lm flag should be available for gcc as far as I can tell. Any ideas?

https://travis-ci.org/StrangeZak/Handmade-Math/jobs/218082438

@DanielGibson
Copy link
Copy Markdown
Contributor

Yep. The problem is basically described at http://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc and http://www.network-theory.co.uk/docs/gccintro/gccintro_18.html
If the problem happens depends on whether the compiler defaults to passing --as-needed to the linker or not.

TL;DR: put the -lfoo after the source/object file that needs it, in your case make -lm the very last argument of the command

@bvisness
Copy link
Copy Markdown
Member Author

bvisness commented Apr 3, 2017

There it is! Thanks for the advice on that. I'm still rather new to compiling C projects, as you can see...

@StrangeZak What do you think? Shall I squash and merge?

@DanielGibson
Copy link
Copy Markdown
Contributor

no problem, I'm glad I could help :)

@strangezakary
Copy link
Copy Markdown
Member

Is this good to merged just noticed this sorry. @bvisness

@bvisness bvisness merged commit cf606db into master Apr 7, 2017
@bvisness bvisness deleted the handmade-test branch July 17, 2017 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doesn't build in C (non-C++) mode

3 participants