Compiler question

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys when I build a C++ program it works if I have not included libc.a…  However functions such as printf don't work.  If I include libc then printf ect work bt c++ runtime such as templates, exceptions and lists fail.

 

Please guys, has anyone a suggestion?

Last Edited: Fri. Feb 21, 2020 - 03:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can the functionality of the I/O functions in the C code be moved to C++?

(in-lieu of, C++ streams?)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:

If I include libc then printf ect work bt c++ runtime such as templates, exceptions and lists fail.

 

This statement doesn't make much sense. You need to explain it better. What "fails" specifically and how? Fails to compile? Fails to link? Fails to run?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The patient says, "Doctor, it hurts when I do this." "Then don't do that!"
 

my projects: https://github.com/epccs

Debugging is harder than programming - don’t write code you can’t debug! https://www.avrfreaks.net/forum/help-it-doesnt-work

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AndreyT wrote:

Fianawarrior wrote:

If I include libc then printf ect work bt c++ runtime such as templates, exceptions and lists fail.

 

This statement doesn't make much sense. You need to explain it better. What "fails" specifically and how? Fails to compile? Fails to link? Fails to run?

 

The system seems to hang when an interrupt occurs.   I would really need to run the debugger to find out more but the problem is likely to be a linker flag to the c/c++ telling it not to do something.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does your combination of libraries have a working malloc() ?

IIRC, the newlib printf() does use malloc() (perhaps even the C++ and C malloc() functions are not compatible?)

(Just grasping at straws.  printf() essentially works fine on Arduinos, which are C++ combined with C...) (once you add the hook for actual IO)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

westfw wrote:

Does your combination of libraries have a working malloc() ?

IIRC, the newlib printf() does use malloc() (perhaps even the C++ and C malloc() functions are not compatible?)

(Just grasping at straws.  printf() essentially works fine on Arduinos, which are C++ combined with C...) (once you add the hook for actual IO)

 

 

Interesting, I tested malloc and it works.  I'll run the debugger tomorrow and see if it sheds anymore light on the matter.  If I was to guess though I would bet my het that it is some weird c/c++ flag required for the linker.  See here... https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you release the files you have?

You're trying to get the ASF C "libraries" callable from C++ projects in AS7, for ARM, right?

I'm sure it's swell that Arduino printf() works, but it doesn't use either Studio or ASF, so for all I know it's a completely different problem.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

westfw wrote:

Can you release the files you have?

You're trying to get the ASF C "libraries" callable from C++ projects in AS7, for ARM, right?

I'm sure it's swell that Arduino printf() works, but it doesn't use either Studio or ASF, so for all I know it's a completely different problem.

 

Hi westfw, it is apart of the Atmel software package 2.15.  I've edited four make files to get C++ working.  In bed here at the moment so I'll not know more until tomorrow.  I going to test it on a example project to rule out the kernel my system is running on.

 

PS: I'm using DS-5 eclipse...

Last Edited: Fri. Feb 21, 2020 - 12:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When I look at your link, it mentions SAM9  So it appears to me that OP is up to his/her old tricks and putting ARM questions into the AVR area, and y'all are again encouraging this by solving problems.  As a guess that is why no simple test program was posted.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

When I look at your link, it mentions SAM9  So it appears to me that OP is up to his/her old tricks and putting ARM questions into the AVR area, and y'all are again encouraging this by solving problems.  As a guess that is why no simple test program was posted.

 

Its a compiler question. indecision

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:
Its a compiler question. 

And here it resides:

Welcome to the Compilers, Assembers, Linkers and General Programming forum for ARM-related discussions

Posted by Michael@Atmel on Wednesday, 30 September 2015 - 14:25

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to clarify, I tested the system and it hangs when an interrupt occurs after calling certain c++ functions such as exceptions.

I tested this with the following piece of code:

 

	start_heartbeat();
	for(int i = 0; i < 20; i++){
		msleep(1000); led_toggle(0);
	}

	templates();
	classes();
	virtual_func();
	name_space_test();
	lists();
	exceptions();

	for(int i = 0; i < 20; i++){
		msleep(1000); led_toggle(0);
	}
	while(1);

start heart beat, starts a timer interrupt. The system fails when the interrupt occurs after calling a c++ function.  

 

Strange!

Last Edited: Fri. Feb 21, 2020 - 07:32 PM