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

Incorrect usage of __FUNCTION__ macro #38

Closed
svigerske opened this issue Feb 22, 2020 · 6 comments
Closed

Incorrect usage of __FUNCTION__ macro #38

svigerske opened this issue Feb 22, 2020 · 6 comments

Comments

@svigerske
Copy link
Member

svigerske commented Feb 22, 2020

Issue created by migration from Trac.

Original creator: asherikov

Original creation time: 2015-07-09 12:23:51

Assignee: ferreau

Version: 3.1.0

Macro __FUNCTION__ is undefined in the global scope. For this reason the following lines in include/qpOASES/MessageHandling.hpp redefine this macro even if the compiler supports it:

#ifndef __FUNCTION__
  /** Ensures that __FUNCTION__ macro is defined. */
  #define __FUNCTION__ 0
#endif

(changed by ferreau at 2015-07-09 12:39:43)

@svigerske
Copy link
Member Author

Comment by ferreau created at 2015-07-09 12:39:43

Changing status from new to assigned.

@svigerske
Copy link
Member Author

Comment by ferreau created at 2015-07-09 12:43:44

While __FILE__ and __LINE__ macros shall be defined according to the C standard, __FUNCTION__ is indeed not a macro thus causing this problem. Any suggestion on how to fix this?

@svigerske
Copy link
Member Author

Comment by asherikov created at 2015-07-09 16:29:59

  1. Stop using __FUNCTION__. Anyway nobody noticed this in the past few years.

  2. Start using __func__ which is part of the new C++11 standard, but is probably not as well supported as __FUNCTION__.

  3. It should be possible to check for existence of __FUNCTION__ using cmake or autotools.

@svigerske
Copy link
Member Author

Comment by ferreau created at 2015-07-20 14:46:12

  1. Let's rather say, nobody reported the bug so far. Probably several local quick fixes are existing around the world. So, great that this is about to change...

  2. I will make this change as a first step to move towards the standard. I have read that __func__ is supposed to be part of C99 as well.

  3. Good idea, but I will not dig into this in the near future.

@svigerske
Copy link
Member Author

Comment by ferreau created at 2015-07-24 16:29:53

Revision 129 of trunk introduces the macro __FUNC__ in the file include/qpOASES/MessageHandling.hpp. This macro is set to a default message, but can be set to __func__ or __FUNCTION__ or any other compiler specific function by the user.

As this effects qpOASES only when compiled with __DEBUG__ compiler flag, it's reasonable to assume that the user has enough inside to change the __FUNC__ macro is needed. By this, I consider this issue solved.

@svigerske
Copy link
Member Author

Comment by ferreau created at 2015-07-24 16:30:00

Resolution: fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant