coin-or / qpOASES

Open-source C++ implementation of the recently proposed online active set strategy
GNU Lesser General Public License v2.1
376 stars 127 forks source link

Incorrect usage of __FUNCTION__ macro #38

Closed svigerske closed 4 years ago

svigerske commented 4 years ago

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 commented 4 years ago

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

Changing status from new to assigned.

svigerske commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

Resolution: fixed