Weird compiling error on special board

Hello,

I use an Attiny88 board. I program it with the Arduino IDE.
When I want to use libraries there are sometimes problems, the code does not want to compile correctly.

Here is an example. I use the library SoftwareI2C. But it seems to cause a problem:

In file included from C:\Users\ordi2113604\Documents\Arduino\libraries\SH1106Lib-master/SH1106Lib.h:21:0,
                 from C:\Users\ordi2113604\Documents\Arduino\1-ordi-lycee\attiny88oledText\attiny88oledText.ino:28:
C:\Users\ordi2113604\Documents\Arduino\libraries\SoftI2CMaster-master\src/SoftI2CMaster.h:347:18: error: missing binary operator before token "("
 #if __has_include("digitalWriteFast.h")
                  ^
exit status 1

Compiling error for MH-ET LIVE Tiny88(16.0MHz) board

Do you understand the error?
I was able to solve it like this but it's probably not a good solution:

#if 1==0     //__has_include("digitalWriteFast.h")

Pourtant cette erreur ne se produit pas quand j'utilise "AttinyCore" pour programmer l'attiny88 à la place d'utiliser "MH-ET LIVE Boards" (officiel).

Comprenez vous pourquoi ceci se passe ? Comment le résoudre ?

It appears to be a problem in the "__has_include" macro.

This 'if block' will always fail and won't be included by the pre-processor...

Is that going to fix or break the issue...?


I'm not familiar with that macro or it's syntax.... It's complaining about a 'binary operator' missing before the '('...

:smiley_cat:

Hi,
Can you please post ALL your code?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Strongly recommend using the ATTinyCore...

Thank you for all your answers !

When I replace with this. I can upload my code without problems, and the program works.

You are right. The library (should I call it library?) AttinyCore seems to be better than the official library.

But I mainly posted this topic to understand this strange problem.
If the problem is in one of the libraries used (here SofwareI2C), why does the compiler not take the error into account when selecting AttinyCore?

Here is the code for my sketch:

/*
 * SH1106Lib\Examples\Text.ino
 * Example sketch demonstrating how use the lib to display text
 * glcdfont.h is part of the Adafruit GFX Library:
 * https://github.com/adafruit/Adafruit-GFX-Library/blob/master/glcdfont.c
 * 
 * 2018, noti
 */

// config for softwareI2Cmaster lib
#define I2C_HARDWARE 1
#define I2C_TIMEOUT 10
#define I2C_MAXWAIT 10
#define I2C_PULLUP 1
#define I2C_FASTMODE 1
#define SDA_PORT PORTC
#define SDA_PIN 4 // = A4
#define SCL_PORT PORTC
#define SCL_PIN 5 // = A5

// config for tinyprint lib
#define TP_PRINTLINES 0
#define TP_FLASHSTRINGHELPER 1
#define TP_NUMBERS 0
#define TP_FLOAT 0
#define TP_WINDOWSLINEENDS 0

#include <SH1106Lib.h>
#include "glcdfont.h"

SH1106Lib display;

void setup() {
  display.initialize();
  display.clearDisplay();

  display.setFont(font, 5, 7);
  display.setTextWrap(true);
  display.setTextColor(WHITE, BLACK);
  delay(1000);
  display.clearDisplay();
  display.setCursor(0,0);
  display.print(F("Hello World"));
}

void loop() {

}

The problematic library .h file:

Does this code work?

This is totally not like the code you first posted.. ?


If these are supplied libraries for your hardware, they should work ... you shouldn't need to 'hack' them ...

If they don't work your hardware/software isn't set up correctly...

Good luck...

:smiley_cat:

Oh? What's so different?

That's to say ? What should I configure?

And why is the compiler making up a "fake" error instead of pointing to the thing that's really wrong?

I really don’t understand...

The board manager core is effectively just another layer of software that sits between your code and the hardware. Think of it a bit like the operating system code.

The code layers all need to match or you will get errors. I suspect there is a mismatch between your sketch, or one of the libraries, and the default core you are using. When you use ATTinyCore this issue goes away.

I have found ATTinyCore to be much better than the default... the biggest advantage is that a lot of work has gone in so that the code that sits above it is much more like the code, that for example would run on an Uno. You don't need special versions of ATTiny code.

1 Like

The cause of the error is that the MH-ET LIVE core uses GCC 4.8.1 which does not support __has_include. ATTinyCore uses GCC 7.3.0 which does.

2 Likes

Thanks a lot.

I understand better now. If ever there is another problem of this type with another board manager, I will know where the problem comes from.

So I will definitely switch to AttinyCore.

A couple tips...

  1. It is an art to learn how to read error messages, but you can do that. You will use that the rest of your life with computers, so pay attention to what kind of messages lead to what causes... irrelevant of the language ... if you use a computer, learn how to read it's complaints.

  2. generally forgotten about is a debugger. When you can look at values while the program is in operation is so much more simple than sprinkling some kind of output statement...

'print' statements are of little use with an embedded micro that has no way to output something during testing/development.


Both of these take time to learn, but the payoff is big and relatively quickly compared to other technical learning curves ...

Good luck -- have fun :crazy_face:

:smiley_cat:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.