Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fabs() vs std::fabs() causing build errors #543

Closed
ghost opened this issue Dec 3, 2015 · 5 comments
Closed

fabs() vs std::fabs() causing build errors #543

ghost opened this issue Dec 3, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Dec 3, 2015

Updating from v1.1 build 3 to 1.2.1 results in numerous compilation errors. This appears to be due to a mixture of C & C++ functions i.e such as fabs() vs std::fabs() used in v1.1. The relevant C header should be included.

/home/smex/NGL/DEV/5000core/../3rd_party/catch/catch.hpp: In function 'bool     Catch::Detail::operator==(double, const Catch::Detail::Approx&)':
/home/smex/NGL/DEV/5000core/../3rd_party/catch/catch.hpp:2140: error: 'fabs' was not declared in this scope
cc: /opt/qnx650/host/linux/x86/usr/lib/gcc/arm-unknown-nto-qnx6.5.0/4.4.2/cc1plus error 1

The issue was produced under GCC 4.4.2 with an empty .CPP file that has a single
line to #include <catch/catch.hpp>

The errors are all due to the use of the 'C' global namespace functions instead of the C++ std:: namespace functions such as fabs()

In many places, the C functions are okay to use as there is an inclusion of which brings in a large amount of C including malloc() and the likes.

@ghost
Copy link
Author

ghost commented Dec 3, 2015

To embellish the details this is using the QNX qcc compiler packaged with QNX v6.5.0. The standard headers do appear to adhere to standard namespace conventions quite well unlike some other libraries where it appears the C 'global' functions are simply pulled into the std:: namespace. Seeing regression since Catch v1.1 it makes you wonder if it were tested on such conformant platform at some stage and possibly this needs to be added to the current set of test setups.

@ghost
Copy link
Author

ghost commented Dec 3, 2015

Attached is a patch which adds the std:: in the places identified from my unit tests. However as the code is templates there may be further code that uses the C global functions.
Catch Patch for std namespace.txt

@ghost
Copy link
Author

ghost commented Dec 21, 2015

This issue is covered under pull request #559

horenmar added a commit that referenced this issue Jan 26, 2017
This should solve #543, once Clara changes are in as well.
@horenmar
Copy link
Member

I just created a branch add-std-namespace-prefixes, that should fix most of these. The last one is in clara.h, which is an external dependency and will have to be fixed independently.

Can you confirm it works for you now?

horenmar added a commit that referenced this issue Feb 11, 2017
This should solve #543, once Clara changes are in as well.
@philsquared
Copy link
Collaborator

This version of Catch will continue with it's own forked version of Clara (as Clara will move on to C++11 and be used by Catch2) - so I just fixed this in-place

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

No branches or pull requests

2 participants