C++ on the AVR port Topic is solved

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderators: utzig, tfAteba

mikenick42
Posts: 28
Joined: Tue Mar 10, 2015 4:49 pm
Been thanked: 1 time

C++ on the AVR port  Topic is solved

Postby mikenick42 » Thu Feb 25, 2021 12:29 am

Has anyone had any luck with C++ on the AVR port of ChibiOS? I know the STM port can do it but when I try renaming main.c and moving it in the Makefile I get:

Code: Select all

/usr/lib/avr/include/avr/io.h:623:6: warning: #warning "device type not defined" [-Wcpp]
 #    warning "device type not defined"


It looks like __AVR_ATmega328P__ isn't being defined for some reason.

Is it even worth using C++? I'm mainly interested in it because it makes encapsulation more convenient. What I want should be possible if I'm careful about how and where I declare things in C, but is a little cleaner in C++.

User avatar
tfAteba
Posts: 542
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 87 times
Been thanked: 48 times

Re: C++ on the AVR port

Postby tfAteba » Mon Jun 14, 2021 1:33 pm

Hello,

No I have never try to compile AVR code with C++ compiler.
regards,

Theo.

davidli
Posts: 6
Joined: Fri Jun 11, 2021 7:15 am

Re: C++ on the AVR port

Postby davidli » Thu Jun 17, 2021 7:40 am

Maybe it only works under windows?

User avatar
tfAteba
Posts: 542
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 87 times
Been thanked: 48 times

Re: C++ on the AVR port

Postby tfAteba » Fri Jun 18, 2021 9:53 pm

Hello Davidli,

No it is not related to OS that you use.

Can yous share me the modification that you made in ChibiOS so that I can try to help.
regards,

Theo.

User avatar
tfAteba
Posts: 542
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 87 times
Been thanked: 48 times

Re: C++ on the AVR port

Postby tfAteba » Wed Nov 23, 2022 12:52 am

Hello Davidli,

I have take some time to look how to use C++ with AVR MCU.
As I said in this thread https://forum.chibios.org/posting.php?mode=reply&f=35&t=6125,
I have create a demo under demos/AVR/RT-ARDUINO-UNO-G++ to show how we can use C++.

It looks like __AVR_ATmega328P__ isn't being defined for some reason.

It was due to the lac of CPP flags in the rules.mk file that is use to build our sources.

Is it even worth using C++? I'm mainly interested in it because it makes encapsulation more convenient. What I want should be possible if I'm careful about how and where I declare things in C, but is a little cleaner in C++.

You can now use C or C++ 8-) .
regards,

Theo.


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 1 guest