9 years, 9 months ago.

need -DNDEBUG in the compile of mbed library for online compiler

Hi,

Since rev86 of mbed library, the object code size of 'mbed_blink' increase 5 timed bigger. I found the following two files are newly introduced in rev86;

mbed/api/mbed_assert.h, and mbed/common/assert.c

I examined these codes and found that NDEBUG macro need to be defined when mbed library is build for online compiler, otherwise, assertion code is embedded in the library.

It's ok for offline compilers as the macro is defined for these environments.

Could you check the build environment of mbed library for online compiler ?

-Yoshi

Yoshitaka Kuwata, morecat_lab

Question relating to:

2 Answers

9 years ago.

Could you add this info in the area of reducing the size of the output code?

A user could use the error messages until he gets successful code compiling and then comment it out to reduce the size of the code when no errors are present.

Accepted Answer

Macros are not persistent

/media/uploads/sam_grove/screen_shot_2015-11-23_at_10.51.21_pm.png

posted by Sam Grove 24 Nov 2015
9 years, 9 months ago.

5x bigger? Can you share the numbers? I don't think assert would cause 5x bigger, in many places error was used. Provide more details

The assertation is enabled in the online IDE by default to provide users a feedback, as you can't debug it to find a cause. For example using NC for a pin which needs to be defined to a real pin.

Thank you for your comment.

On LPC1114 platform, compile "mbed_blinky" with Rev85 mbed-lib, I got an object with 1.7KB flash. On LPC1114 platform, compile "mbed_blinky" with Rev86 mbed-lib, I got an object with 10KB flash.

well, 6 times bigger.

posted by Yoshitaka Kuwata 20 Feb 2015

Hi,

This is not a small impact, if the platform does not have large flash memory space. e.g. LPC1114 has only 32kB flash memory.

I personally think the LPC1114 (or other small flash targets) should disable the assert message at runtime. This can be configured in the device.h for each target.

#define DEVICE_STDIO_MESSAGES   0

Any thoughts?

posted by Toyomasa Watarai 20 Feb 2015

Users would loose the only debugging messages they get from the online compiler :/

posted by Martin Kojtal 21 Feb 2015

I agree that assertion messages are useful for debugging. Do you have any plan to release non-debugging version of mbed library ? You have source code version (mbed-src) already in your lineup. 'mbed-no-debug', or 'mbed-release' version will be also useful for those who want to use mbed lib for practical applications.

posted by Yoshitaka Kuwata 23 Feb 2015