GithubHelp home page GithubHelp logo

"not a constant expression" error about a21 HOT 7 CLOSED

aleh avatar aleh commented on August 22, 2024
"not a constant expression" error

from a21.

Comments (7)

aleh avatar aleh commented on August 22, 2024

Thanks for reporting this!

Apparently the above happens in newer versions of Arduino IDE because of a change in GCC that does not allow constant expressions to contain pointers constructed from integers, something that port addresses are on AVR, see the discussion here, for example, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49171#c18.

I am trying to work around this annoying rule now by using constexpr functions instead. I'll keep you posted.

from a21.

aleh avatar aleh commented on August 22, 2024

@kurogedelic It should be working with the new version as well now, could you please try?

from a21.

kurogedelic avatar kurogedelic commented on August 22, 2024

@aleh Thank you.
I tried the new version. With your "NoiseChip.ino." But it can't worked.
It shows different error messages.
The "not a constant expression" error is no longer visibled.

Arduino:1.8.13 (Mac OS X), TD: 1.53, Board: "ATtiny25/45/85, ATtiny85, Internal 1 MHz"

In file included from /Users/<user>/Documents/Arduino/libraries/a21-master/a21/pcd8544.hpp:12:0,
				 from /Users/<user>/Documents/Arduino/libraries/a21-master/a21.hpp:16,
				 from /Users/<user>/NoiseChip/NoiseChip.ino:18:
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/flashstring.hpp:11:9: error: 'fstr_t' does not name a type; did you mean 'fpos_t'?
 typedef fstr_t *FlashStringPtr;
		 ^~~~~~
		 fpos_t
In file included from /Users/<user>/Documents/Arduino/libraries/a21-master/a21.hpp:16:0,
				 from /Users/<user>/NoiseChip/NoiseChip.ino:18:
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/pcd8544.hpp:478:14: error: 'FlashStringPtr' has not been declared
   void print(FlashStringPtr str) {
			  ^~~~~~~~~~~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/pcd8544.hpp:486:8: error: 'void a21::PCD8544Console<lcd, font>::print(int)' cannot be overloaded
   void print(int n) {
		^~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/pcd8544.hpp:478:8: error: with 'void a21::PCD8544Console<lcd, font>::print(int)'
   void print(FlashStringPtr str) {
		^~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/pcd8544.hpp:515:16: error: 'FlashStringPtr' has not been declared
   void println(FlashStringPtr str) {
				^~~~~~~~~~~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/pcd8544.hpp:520:8: error: 'void a21::PCD8544Console<lcd, font>::println(int)' cannot be overloaded
   void println(int n) {
		^~~~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/pcd8544.hpp:515:8: error: with 'void a21::PCD8544Console<lcd, font>::println(int)'
   void println(FlashStringPtr str) {
		^~~~~~~
In file included from /Users/<user>/Documents/Arduino/libraries/a21-master/a21.hpp:18:0,
				 from /Users/<user>/NoiseChip/NoiseChip.ino:18:
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/print.hpp:38:20: error: 'FlashStringPtr' has not been declared
  static void print(FlashStringPtr str) {
					^~~~~~~~~~~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/print.hpp:46:14: error: 'static void a21::Print<T>::print(int)' cannot be overloaded
  static void print(int n) {
			  ^~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/print.hpp:38:14: error: with 'static void a21::Print<T>::print(int)'
  static void print(FlashStringPtr str) {
			  ^~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/print.hpp:75:22: error: 'FlashStringPtr' has not been declared
  static void println(FlashStringPtr str) {
					  ^~~~~~~~~~~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/print.hpp:80:14: error: 'static void a21::Print<T>::println(int)' cannot be overloaded
  static void println(int n) {
			  ^~~~~~~
/Users/<user>/Documents/Arduino/libraries/a21-master/a21/print.hpp:75:14: error: with 'static void a21::Print<T>::println(int)'
  static void println(FlashStringPtr str) {
			  ^~~~~~~
exit status 1

from a21.

aleh avatar aleh commented on August 22, 2024

@kurogedelic Hey, thanks for reporting again!

The NoiseChip indeed fails to build for the ATtiny board definition that you are using. It turns out that Digispark (that I was targeting for ATtiny projects) has a different idea of program space string type, while yours follows the regular Arduino way. I've corrected that definition to be used only for Digispark boards, not every time an ATtiny is involved. Please pull and try building again.

Thanks!

from a21.

aleh avatar aleh commented on August 22, 2024

@kurogedelic Hey! Did you have a chance to test this again perhaps?

from a21.

kurogedelic avatar kurogedelic commented on August 22, 2024

@aleh
I'm sorry to have you waiting.
The compilation was passed successfully.
And that works fine on my ATtiny.
Thanks for your great program.

from a21.

aleh avatar aleh commented on August 22, 2024

Glad to hear it works! Thanks a lot!

from a21.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.