mbeddr / mbeddr.core

The mbeddr core. An extensible C
Eclipse Public License 2.0
224 stars 77 forks source link

Prevent name mangling option and external APIs #2015

Open BjoernLange opened 5 years ago

BjoernLange commented 5 years ago

The mbeddr User Guide says in section 5.2:

The second option is to select the prevent name mangling configuration item in the build configuration. This will try to get rid of the prefixes where possible, i.e., if an only if a non-prefixed name is globally unique within an executable. This optimization is performed each time you rebuild your code.

However, it is possible to define a function with the same name as an external function in mbeddr code and its name will not be mangled although it would be required to generate valid code. An example for this behavior is com.mbeddr.core.unittest.runtime.UnitTestUtil which defines the strrchr function that collides with the strrchr function from string.h. In my opinion, the strrchr function name should be mangled in this case (according to the quote given above).

stephaneberle9 commented 5 years ago

Hi Björn,

Yes, this looks like a bug and should be recorded as such (i.e., GitHub issue).

Btw, the specific case of the conflicting strrchr function in com.mbeddr.core.unittest.runtime.UnitTestUtil has already been addressed by renaming the very same function to strreplchr.

Regards,

Stephan

Am Di., 20. Nov. 2018 um 09:39 Uhr schrieb Björn Lange < notifications@github.com>:

The mbeddr User Guide http://mbeddr.com/userguide/UserGuideExport.html says in section 5.2 http://mbeddr.com/userguide/UserGuideExport.html#sid3082376456307360126:

The second option is to select the prevent name mangling configuration item in the build configuration. This will try to get rid of the prefixes where possible, i.e., if an only if a non-prefixed name is globally unique within an executable. This optimization is performed each time you rebuild your code.

However, it is possible to define a function with the same name as an external function in mbeddr code and its name will not be mangled although it would be required to generate valid code. An example for this behavior is com.mbeddr.core.unittest.runtime.UnitTestUtil which defines the strrchr function that collides with the strrchr function from string.h. In my opinion, the strrchr function name should be mangled in this case (according to the quote given above).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mbeddr/mbeddr.core/issues/2015, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2kAI-6AxuTLjV6hXpHKAGvQr40AQFPks5uw7-wgaJpZM4Yqnfr .

stephaneberle9 commented 5 years ago

Yes, this looks like a valid error that must be corrected bug.

Btw, the specific case of the conflicting strrchr function in com.mbeddr.core.unittest.runtime.UnitTestUtilhas already been addressed by renaming the very same function to strreplchr.