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

'Float' number_float_function_t template parameter name conflicts with C '#define Float float' #1775

Closed
CraigHutchinson opened this issue Oct 4, 2019 · 4 comments
Labels
kind: bug solution: invalid the issue is not related to the library solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)

Comments

@CraigHutchinson
Copy link

  • What is the issue you have?
    'Float' number_float_function_t template parameter name conflicts with C #define Float float:
template <typename T, typename Float, typename String>
using number_float_function_t..
  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
  1. #define Float float
  2. Include json.hpp
  • What is the expected behavior?
    Compilation should succeed as Template parameter shall be unlike standard type names e.g. FloatT instead of Float to prevent collisions.

  • And what is the actual behavior instead?
    Msvc 2017: error C2993: 'float': illegal type for non-type template parameter '__formal'

  • Which compiler and operating system are you using? Is it a supported compiler?
    Msvc 2017

  • Did you use a released version of the library or the version from the develop branch?
    3.7.0

  • If you experience a compilation error: can you compile and run the unit tests?

@gregmarr
Copy link
Contributor

gregmarr commented Oct 4, 2019

Where is this #define coming from? This seems like a dangerous thing to define.

@CraigHutchinson
Copy link
Author

This is from a 3rd-party legacy library sadly. In some cases I have seen a custom 'Float' type in c++ also especially in heavy embedded realm where you need to roll your own soft-implementation but its the nasty #define of C society that hurts here!

@gregmarr
Copy link
Contributor

gregmarr commented Oct 4, 2019

Can you change the order of the #include lines to put this library first or put an #undef Float before the include of this library?

@CraigHutchinson
Copy link
Author

CraigHutchinson commented Oct 7, 2019

Not as easy as just changing the Float to FloatT in the json.h though so I went with this option strangely enough as its 2 characters change to the code fyi :)

@nlohmann nlohmann added solution: invalid the issue is not related to the library solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope) labels Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug solution: invalid the issue is not related to the library solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)
Projects
None yet
Development

No branches or pull requests

3 participants