Re: [Mspgcc-users] mspg++ and c++ includes
Hi, I suspect your choice of command line is the issue - there is a difference between msp430-gcc and msp430-g++. I am not an expert here - I've only played around with C++ a little - but my understanding is that msp430-gcc and msp430-g++ work the same for compiling, but pick different default libraries when used for the link stage. If you want to use the standard C libraries (to get the non-inlined, non-builtin version of memset, for example, or to get printf), then you should link with mps430-gcc and not use -nodefaultlibs. If you need to link to the c++ libraries - if and when they are available - use msp430-g++ (or include them specifically on the command line). The only thing I am not sure about is when global constructors are called (before main() starts). It is possible that the file containing main() has to be compiled with msp430-g++ to work correctly - I don't know the details here, but I urge you to check that it is working correctly. mvh., David On 11/06/13 02:23, Thomas Taranowski wrote: Thanks for the comment Paul. What are you using for your compiler flags? I'm having a couple issues with mine. I'm currently using the following: -ffunction-sections -fdata-sections -DGCC_MSP430 -Wall -fno-exceptions -fno-rtti -fno-enforce-eh-specs -nodefaultlibs This works well in with -O2 specified (release build), but fails with memset undefined when running my -O0 debug build. Presumably the optimized version is using the built-in library. Also, I can't seem to get printf back in by adding -lgcc -lc.to the linker flags, as I think these get ignored after specifying the -nodefaultlibs argument. I really want something to just disable the libstdc++ include. Thomas Taranowski | 425-442-9209 | skype: thomas.taranowski | baringforge.com On Mon, Jun 10, 2013 at 5:00 PM, Paul Sokolovsky pmis...@gmail.com wrote: Hello, On Mon, 10 Jun 2013 17:45:00 -0500 Peter Bigot big...@acm.org wrote: C++ is not supported by mspgcc. Some people are using it to some degree with some success, and may be able to provide hints about improved compatibility, but no effort has been made to ensure it functions. C++ as a language works really well with mspgcc. Well, C++ is big and multi-paradigm, the part which is good for embedded works well (that includes compile-time meta-programming and excludes run-time cycle-burning, like virtual functions). Well, it sucks that things like: = struct Timer { const static int irq_no = 10; }; interrupt(Timer::irq_no) irq_handler() { } = don't work, but I put up with that. C++ stdlib is different story. I recently did a survey of MCU C++ libs and found it funny that almost everyone (including me) had circular.hpp or similar in their codebase. So, good-for-embedded things of STL (like, well, template classes) are definitely a miss and people reinvent the wheel. https://github.com/vancegroup/stlport-avr may be a good start to get those. It is to be hoped this will be addressed by Red Hat's version. On Mon, Jun 10, 2013 at 5:34 PM, Thomas Taranowski t...@baringforge.comwrote: mspg++ seems to be functioning, but all the standard c++ includes seen to be missing. For example, cstdio, cstdlib, etc. Am I missing some part of the install, or is this work yet to be done? -Tom -- Best regards, Paul mailto:pmis...@gmail.com -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
Hello, On Mon, 10 Jun 2013 17:23:00 -0700 Thomas Taranowski t...@baringforge.com wrote: Thanks for the comment Paul. What are you using for your compiler flags? I'm having a couple issues with mine. I'm currently using the following: -ffunction-sections -fdata-sections -DGCC_MSP430 -Wall -fno-exceptions -fno-rtti -fno-enforce-eh-specs -nodefaultlibs Well, I'm using: msp430-g++ -I../include/ -mmcu=msp430g2553 -O1 -g -Wreturn-type -ffunction-sections -fdata-sections -DHW_CONFIG=\hw_config_msp430.hpp\ -fno-exceptions -c blink.cpp -o bin-msp430/blink.o msp430-gcc -mmcu=msp430g2553 -Wl,--gc-sections -Wl,-Map=bin-msp430/blink.map,--cref bin-msp430/blink.o -o bin-msp430/blink (I was shocked to see that Energia doesn't pass -fno-exceptions, but I myself don't pass -fno-rtti, that needs to be fixed). This works well in with -O2 specified (release build), but fails with memset undefined when running my -O0 debug build. Presumably the optimized version is using the built-in library. Also, I can't seem to get printf back in by adding -lgcc -lc.to the linker flags, as I think these get ignored after specifying the -nodefaultlibs argument. I really want something to just disable the libstdc++ include. Thomas Taranowski | 425-442-9209 | skype: thomas.taranowski | baringforge.com -- Best regards, Paul mailto:pmis...@gmail.com -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
Hello, On Mon, 10 Jun 2013 23:00:43 -0400 Peter Johansson rockets4k...@gmail.com wrote: On Mon, Jun 10, 2013 at 8:00 PM, Paul Sokolovsky pmis...@gmail.com wrote: C++ as a language works really well with mspgcc. C++ stdlib is different story. The vast majority of MSP430s are rather limited in capabilities and this is borne out in even in the C library. Outside of the micro-controller realm, many people use C++ (effectively) for the library support, and that is one thing you won't get for any small micro. These are tales from previous century. There were dispelled many times (e.g. http://stackoverflow.com/questions/812717/is-there-any-reason-to-use-c-instead-of-c-for-embedded-development), including by respectable organizations (http://www.open-std.org/jtc1/sc22/wg21/docs/TR18015.pdf). Of course, that's party due to fact that when people hear C++, they picture 30-old C++ with objects which are by now a trivial thing, or or poor implementation of exceptions, or something. When speaking about C++, one rather should imagine Lisp with its macros and how they were twisted into templates which gave birth to modern C++ and is its central part. If you want to venture into the world of C++ for micros, you are going to be writing your own libraries. Yes, that's how it has been for now, example was given. I also gave an example that it changes and will be changing further (someone will drop -avr from that stlport port, because there's of course nothing in there which got to be AVR-specific in it). At least one person on this list has put the C++ capabilities of mspgcc to excellent use. Perhaps he might be persuaded to share... I humbly can propose my piece: https://github.com/pfalcon/PeripheralTemplateLibrary is a humbly named (template) lib with the aim of providing consistent programming interface (up to the level of writing portable apps) for all possible and impossible MCUs (8051 is in queue too, blocked by lack of open-source C++ compiler for it), without sacrificing performance (should be much better than any C lib with similar aims and not much worse than Asm). -p. -- Best regards, Paul mailto:pmis...@gmail.com -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
I believe (without checking) that since mspgcc doesn't support C++ exceptions the default is -fno-exceptions. I suspect rtti is also off by default, but I don't have the vague reminiscence of having made sure of that. On Tue, Jun 11, 2013 at 4:39 AM, Paul Sokolovsky pmis...@gmail.com wrote: Hello, On Mon, 10 Jun 2013 17:23:00 -0700 Thomas Taranowski t...@baringforge.com wrote: Thanks for the comment Paul. What are you using for your compiler flags? I'm having a couple issues with mine. I'm currently using the following: -ffunction-sections -fdata-sections -DGCC_MSP430 -Wall -fno-exceptions -fno-rtti -fno-enforce-eh-specs -nodefaultlibs Well, I'm using: msp430-g++ -I../include/ -mmcu=msp430g2553 -O1 -g -Wreturn-type -ffunction-sections -fdata-sections -DHW_CONFIG=\hw_config_msp430.hpp\ -fno-exceptions -c blink.cpp -o bin-msp430/blink.o msp430-gcc -mmcu=msp430g2553 -Wl,--gc-sections -Wl,-Map=bin-msp430/blink.map,--cref bin-msp430/blink.o -o bin-msp430/blink (I was shocked to see that Energia doesn't pass -fno-exceptions, but I myself don't pass -fno-rtti, that needs to be fixed). This works well in with -O2 specified (release build), but fails with memset undefined when running my -O0 debug build. Presumably the optimized version is using the built-in library. Also, I can't seem to get printf back in by adding -lgcc -lc.to the linker flags, as I think these get ignored after specifying the -nodefaultlibs argument. I really want something to just disable the libstdc++ include. Thomas Taranowski | 425-442-9209 | skype: thomas.taranowski | baringforge.com -- Best regards, Paul mailto:pmis...@gmail.com -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
Hi, I'm new to MSP programming and ran into this very same issue. I found out that compiling with msp430-g++ cpp -c -o o msp430-gcc o -o bin works well. However, it does not optimize as much as I'd like it to. Reading the gcc man page, it seem that it determines language based on the file extension, so we can use msp430-gcc with a .cpp file and it will recognize it as C++. Since I couldn't get -flto to work (but didn't bother much), I compile with: msp430-gcc -Os -Wall -g -mmcu=msp430g2553 -std=c++0x -fwhole-program -I../../PeripheralTemplateLibrary/include/ cpp -o bin (There are some flags in the mails above that I still have to check!) MSPGCC ships with a standard C library that can be of use. In order to use it this way, you must enclose your includes in an extern C block like: extern C { #include stdlib.h } and it works well. Also, I strongly recommend using the Peripheral Template Library. It works quite well, makes code an order of magnitude simpler and, if you read the sources, it provides good examples and helps making sense of all those register names :) João Reis On Tue, Jun 11, 2013 at 12:02 PM, Peter Bigot big...@acm.org wrote: I believe (without checking) that since mspgcc doesn't support C++ exceptions the default is -fno-exceptions. I suspect rtti is also off by default, but I don't have the vague reminiscence of having made sure of that. On Tue, Jun 11, 2013 at 4:39 AM, Paul Sokolovsky pmis...@gmail.com wrote: Hello, On Mon, 10 Jun 2013 17:23:00 -0700 Thomas Taranowski t...@baringforge.com wrote: Thanks for the comment Paul. What are you using for your compiler flags? I'm having a couple issues with mine. I'm currently using the following: -ffunction-sections -fdata-sections -DGCC_MSP430 -Wall -fno-exceptions -fno-rtti -fno-enforce-eh-specs -nodefaultlibs Well, I'm using: msp430-g++ -I../include/ -mmcu=msp430g2553 -O1 -g -Wreturn-type -ffunction-sections -fdata-sections -DHW_CONFIG=\hw_config_msp430.hpp\ -fno-exceptions -c blink.cpp -o bin-msp430/blink.o msp430-gcc -mmcu=msp430g2553 -Wl,--gc-sections -Wl,-Map=bin-msp430/blink.map,--cref bin-msp430/blink.o -o bin-msp430/blink (I was shocked to see that Energia doesn't pass -fno-exceptions, but I myself don't pass -fno-rtti, that needs to be fixed). This works well in with -O2 specified (release build), but fails with memset undefined when running my -O0 debug build. Presumably the optimized version is using the built-in library. Also, I can't seem to get printf back in by adding -lgcc -lc.to the linker flags, as I think these get ignored after specifying the -nodefaultlibs argument. I really want something to just disable the libstdc++ include. Thomas Taranowski | 425-442-9209 | skype: thomas.taranowski | baringforge.com -- Best regards, Paul mailto:pmis...@gmail.com -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
[Mspgcc-users] mspg++ and c++ includes
mspg++ seems to be functioning, but all the standard c++ includes seen to be missing. For example, cstdio, cstdlib, etc. Am I missing some part of the install, or is this work yet to be done? -Tom -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
C++ is not supported by mspgcc. Some people are using it to some degree with some success, and may be able to provide hints about improved compatibility, but no effort has been made to ensure it functions. It is to be hoped this will be addressed by Red Hat's version. On Mon, Jun 10, 2013 at 5:34 PM, Thomas Taranowski t...@baringforge.comwrote: mspg++ seems to be functioning, but all the standard c++ includes seen to be missing. For example, cstdio, cstdlib, etc. Am I missing some part of the install, or is this work yet to be done? -Tom -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
Hello, On Mon, 10 Jun 2013 17:45:00 -0500 Peter Bigot big...@acm.org wrote: C++ is not supported by mspgcc. Some people are using it to some degree with some success, and may be able to provide hints about improved compatibility, but no effort has been made to ensure it functions. C++ as a language works really well with mspgcc. Well, C++ is big and multi-paradigm, the part which is good for embedded works well (that includes compile-time meta-programming and excludes run-time cycle-burning, like virtual functions). Well, it sucks that things like: = struct Timer { const static int irq_no = 10; }; interrupt(Timer::irq_no) irq_handler() { } = don't work, but I put up with that. C++ stdlib is different story. I recently did a survey of MCU C++ libs and found it funny that almost everyone (including me) had circular.hpp or similar in their codebase. So, good-for-embedded things of STL (like, well, template classes) are definitely a miss and people reinvent the wheel. https://github.com/vancegroup/stlport-avr may be a good start to get those. It is to be hoped this will be addressed by Red Hat's version. On Mon, Jun 10, 2013 at 5:34 PM, Thomas Taranowski t...@baringforge.comwrote: mspg++ seems to be functioning, but all the standard c++ includes seen to be missing. For example, cstdio, cstdlib, etc. Am I missing some part of the install, or is this work yet to be done? -Tom -- Best regards, Paul mailto:pmis...@gmail.com -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
Thanks for the comment Paul. What are you using for your compiler flags? I'm having a couple issues with mine. I'm currently using the following: -ffunction-sections -fdata-sections -DGCC_MSP430 -Wall -fno-exceptions -fno-rtti -fno-enforce-eh-specs -nodefaultlibs This works well in with -O2 specified (release build), but fails with memset undefined when running my -O0 debug build. Presumably the optimized version is using the built-in library. Also, I can't seem to get printf back in by adding -lgcc -lc.to the linker flags, as I think these get ignored after specifying the -nodefaultlibs argument. I really want something to just disable the libstdc++ include. Thomas Taranowski | 425-442-9209 | skype: thomas.taranowski | baringforge.com On Mon, Jun 10, 2013 at 5:00 PM, Paul Sokolovsky pmis...@gmail.com wrote: Hello, On Mon, 10 Jun 2013 17:45:00 -0500 Peter Bigot big...@acm.org wrote: C++ is not supported by mspgcc. Some people are using it to some degree with some success, and may be able to provide hints about improved compatibility, but no effort has been made to ensure it functions. C++ as a language works really well with mspgcc. Well, C++ is big and multi-paradigm, the part which is good for embedded works well (that includes compile-time meta-programming and excludes run-time cycle-burning, like virtual functions). Well, it sucks that things like: = struct Timer { const static int irq_no = 10; }; interrupt(Timer::irq_no) irq_handler() { } = don't work, but I put up with that. C++ stdlib is different story. I recently did a survey of MCU C++ libs and found it funny that almost everyone (including me) had circular.hpp or similar in their codebase. So, good-for-embedded things of STL (like, well, template classes) are definitely a miss and people reinvent the wheel. https://github.com/vancegroup/stlport-avr may be a good start to get those. It is to be hoped this will be addressed by Red Hat's version. On Mon, Jun 10, 2013 at 5:34 PM, Thomas Taranowski t...@baringforge.comwrote: mspg++ seems to be functioning, but all the standard c++ includes seen to be missing. For example, cstdio, cstdlib, etc. Am I missing some part of the install, or is this work yet to be done? -Tom -- Best regards, Paul mailto:pmis...@gmail.com -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
On Mon, Jun 10, 2013 at 8:00 PM, Paul Sokolovsky pmis...@gmail.com wrote: C++ as a language works really well with mspgcc. C++ stdlib is different story. The vast majority of MSP430s are rather limited in capabilities and this is borne out in even in the C library. Outside of the micro-controller realm, many people use C++ (effectively) for the library support, and that is one thing you won't get for any small micro. If you want to venture into the world of C++ for micros, you are going to be writing your own libraries. At least one person on this list has put the C++ capabilities of mspgcc to excellent use. Perhaps he might be persuaded to share... -p. -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] mspg++ and c++ includes
On Jun 10, 2013, at 5:23 PM, Thomas Taranowski wrote: I really want something to just disable the libstdc++ include. Energia (Arduino for MSP430) is probably the most common MSP430 C++ application, and it doesn't seem to do anything special, nor include (in it's distribution) ANY C++ libraries It's msp430-g++ (MSPGCC 20120406 (With patches: sf3540953 sf3559978)) 4.6.3 20120301 (mspgcc LTS 20120406 unpatched) and does: .../hardware/tools/msp430/bin/msp430-g++ -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=msp430g2452 -DF_CPU=1600L -MMD -DARDUINO=101 -DENERGIA=9 -I.../hardware/msp430/cores/msp430 -I.../hardware/msp430/variants/launchpad Blink.cpp -o Blink.cpp.o : .../hardware/tools/msp430/bin/msp430-gcc -Os -Wl,-gc-sections,-u,main -mmcu=msp430g2452 -o Blink.cpp.elf Blink.cpp.o core.a -L/var/folders/jz/5yb8f2hr8xjcpf0059bsfz4rgn/T/build2826063411927392333.tmp -lm -- This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users