fixed point support in avr-g++ compiler

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

Hello everybody :)

I have the following Problem:

I want to compile:

#include <avr/io.h>
#include <stdfix.h>

int main() {

    accum x;
}

which I can do so using avr-gcc.

In my current project however I am using the avr-g++ compiler. It seems that fixed point support is not included in the c++ compiler?

I get:

avr-g++ -g -Os -DF_CPU=16000000 -mmcu=atmega328p -c main.c
In file included from /usr/local/lib/gcc/avr/6.5.0/include/stdfix.h:36:0,
                 from main.c:1:
main.c: In function 'int main()':
main.c:5:5: error: '_Accum' was not declared in this scope
     accum x;
     ^

I tried this with the avr-gcc versions 9.1 and 6.5. I compiled these myself with the --enable-fixed-point option during the configuration (../configure --target=avr --enable-languages=c,c++ --enable-fixed-point --disable-nls --disable-libssp --with-dwarf2).

Did any of you experience the same issue?

Kind regards

Christian

This topic has a solution.
Last Edited: Mon. Aug 5, 2019 - 05:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is only available in C, not in C++.

avrfreaks does not support Opera. Profile inactive.

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

...I see.
I guess one needs quite a lot of experience to port this to the c++ compiler?

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

Why not write the fixed stuff in C and the rest in C++ then? You just need extern "C" to access the C functions from C++

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

Yes I already thought about this as an option. Porting it to the C++ compiler would only make it a bit more conveniant and avoid casts between the modules. But for now I decided to use „extern“ C functions. Thank you all for your replies.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Honeypot wrote:
It seems that fixed point support is not included in the c++ compiler?
Possibly in C++23.

Composition of Arithmetic Types

via

2019-07 Cologne ISO C++ Committee Trip Report — 🚀 The C++20 Eagle has Landed 🚀 (C++20 Committee Draft shipped; Contracts Moved From C++20 to a Study Group; `std::format` in C++20; C++20 Synchronization Library) : cpp

...

 

Library Evolution Working Group Incubator (LEWGI) Progress

...

...

GitHub - johnmcfarlane/cnl: A Compositional Numeric Library for C++

via

The Embedded Muse 361 - Tools and Tips

...

 

Readers contributed ideas about fixed-point math last issue, and John Lagerquist had some thoughts:

...

 

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