9 years, 4 months ago.

compile errors

Hello Neal, I import the library and enter the code in example in main.cpp but compiler show many errors:

Error: Expected either a definition or a tag name in "main.cpp", Line: 7, Col: 7 Error: Expected a ")" in "main.cpp", Line: 10, Col: 5 Error: Expected a type specifier in "main.cpp", Line: 10, Col: 5 Error: Function returning function is not allowed in "main.cpp", Line: 10, Col: 10 Error: Expected a ";" in "main.cpp", Line: 10, Col: 51 Warning: Parsing restarts here after previous syntax error in "main.cpp", Line: 14, Col: 6 Error: Expected either a definition or a tag name in "main.cpp", Line: 18, Col: 7 Error: Expected a ")" in "main.cpp", Line: 21, Col: 5 Error: Expected a type specifier in "main.cpp", Line: 21, Col: 5 Error: Function returning function is not allowed in "main.cpp", Line: 21, Col: 10 Error: Expected a ";" in "main.cpp", Line: 21, Col: 36 Warning: Parsing restarts here after previous syntax error in "main.cpp", Line: 25, Col: 6 Error: Expected a ")" in "main.cpp", Line: 28, Col: 2 Error: Expected a type specifier in "main.cpp", Line: 28, Col: 2 Error: Explicit type is missing ("int" assumed) in "main.cpp", Line: 28, Col: 2 Error: "SPI_TypeDef" has already been declared in the current scope in "main.cpp", Line: 28, Col: 2 Error: Expected a "{" in "main.cpp", Line: 28, Col: 6 Warning: Parsing restarts here after previous syntax error in "main.cpp", Line: 35, Col: 12 Error: Identifier "gOled1" is undefined in "main.cpp", Line: 37, Col: 9 Error: Identifier "gOled2" is undefined in "main.cpp", Line: 38, Col: 9

May You help me Please, May be I make some global error...

Question relating to:

A derived version of the BSD licensed Adafrut GFX library for the SSD1306 controller for an OLED 128x32 or 128x64 display using SPI or I2C. display, I2C, OLED, SPI, SSD1306

I'm not seeing the problem in my environment.

I opened the Compiler IDE;

  • 1. Started a New program, used the Blinky Template.
  • 2. Imported gfx library
  • 3. Copied my example from the library page to the clipboard, selected all the Blinky code in the compiler and then pasted.

It, compiled, with no errors.

I also tried your way;

  • 1. Started new empty program
  • 2. Added new file main.cpp
  • 3. Pasted example code
  • 4. Imported gfx library
  • 5. Imported mbed library
  • 6. Compiled, with no errors

I'm using an LPC1768, I don't have a Nucleo device to test on.

The errors look like the base SPI and I2C classes don't exist.

posted by Neal Horman 11 Dec 2014

5 Answers

6 years, 3 months ago.

Error: Expected an identifier in "main.cpp", Line: 3, Col: 8 Error: Expected a type specifier in "main.cpp", Line: 3, Col: 16 Error: Expected an identifier in "main.cpp", Line: 4, Col: 8 Error: This declaration has no storage class or type specifier in "main.cpp", Line: 5, Col: 2 Error: Identifier "SS" is undefined in "main.cpp", Line: 5, Col: 15 Error: Expected a ")" in "main.cpp", Line: 5, Col: 17 Error: Expected an identifier in "main.cpp", Line: 6, Col: 5 Error: Expected an identifier in "main.cpp", Line: 7, Col: 5 Error: Identifier "SPI_CLOCK_DIV8" is undefined in "main.cpp", Line: 7, Col: 22 Error: Expected a "{" in "main.cpp", Line: 9, Col: 2 Error: Identifier "byte" is undefined in "main.cpp", Line: 11, Col: 4 Error: Type name is not allowed in "main.cpp", Line: 11, Col: 13 Error: Identifier "what" is undefined in "main.cpp", Line: 11, Col: 27 Error: Identifier "delayMicroseconds" is undefined in "main.cpp", Line: 12, Col: 4 Error: Identifier "byte" is undefined in "main.cpp", Line: 17, Col: 2 Error: Expression preceding parentheses of apparent call must have (pointer-to-) function type in "main.cpp", Line: 20, Col: 4 Error: Identifier "LOW" is undefined in "main.cpp", Line: 20, Col: 21 Error: Identifier "transferAndWait" is undefined in "main.cpp", Line: 22, Col: 4 Error: Expression preceding parentheses of apparent call must have (pointer-to-) function type in "main.cpp", Line: 30, Col: 4 Error: Identifier "HIGH" is undefined in "main.cpp", Line: 30, Col: 21 Error: Expected an identifier in "main.cpp", Line: 32, Col: 10 Error: Expected a type specifier in "main.cpp", Line: 32, Col: 20 Error: Expected an identifier in "main.cpp", Line: 33, Col: 10 Error: Variable "a" is not a type name in "main.cpp", Line: 33, Col: 20 Error: Identifier "DEC" is undefined in "main.cpp", Line: 33, Col: 23 Error: Expected an identifier in "main.cpp", Line: 34, Col: 10 Error: Variable "b" is not a type name in "main.cpp", Line: 34, Col: 20 Error: Identifier "DEC" is undefined in "main.cpp", Line: 34, Col: 23 Error: Expected an identifier in "main.cpp", Line: 35, Col: 10 Error: Variable "c" is not a type name in "main.cpp", Line: 35, Col: 20 Info: Unable to download. Fix the reported errors...

Posting a list of errors without any explanation as an answer to a 3 year old question isn't going to get you much help. Post a new question including code and which board you are using. If the problem is basically the same as in this question also include a link to this question and details of what happened when you tried the solutions listed here.

posted by Andy A 19 Dec 2017
9 years, 2 months ago.

How do I get this to work on a Nucleo? I have created a new program and imported the library and using an exact copy of the example but I get compile errors:

Error: Expected a ")" in "main.cpp", Line: 22, Col: 5
Error: Expected a type specifier in "main.cpp", Line: 22, Col: 5
Error: Function returning function is not allowed in "main.cpp", Line: 22, Col: 10
Error: Expected a ";" in "main.cpp", Line: 22, Col: 50
Warning: Parsing restarts here after previous syntax error in "main.cpp", Line: 26, Col: 6
Error: Expected a ")" in "main.cpp", Line: 33, Col: 5
Error: Expected a type specifier in "main.cpp", Line: 33, Col: 5
Error: Function returning function is not allowed in "main.cpp", Line: 33, Col: 10
Error: Expected a ";" in "main.cpp", Line: 33, Col: 36
Warning: Parsing restarts here after previous syntax error in "main.cpp", Line: 37, Col: 6
Error: Identifier "p5" is undefined in "main.cpp", Line: 40, Col: 17
Error: Identifier "p7" is undefined in "main.cpp", Line: 40, Col: 23
Error: No instance of constructor "SPIPreInit::SPIPreInit" matches the argument list in "main.cpp", Line: 40, Col: 17
Error: Identifier "p26" is undefined in "main.cpp", Line: 41, Col: 34
Error: Identifier "p25" is undefined in "main.cpp", Line: 41, Col: 38
Error: Identifier "p24" is undefined in "main.cpp", Line: 41, Col: 42
Error: Identifier "p9" is undefined in "main.cpp", Line: 43, Col: 17
Error: Identifier "p10" is undefined in "main.cpp", Line: 43, Col: 20
Error: No instance of constructor "I2CPreInit::I2CPreInit" matches the argument list in "main.cpp", Line: 43, Col: 17
Error: Identifier "p27" is undefined in "main.cpp", Line: 44, Col: 34

There may be more issues, but the pinnames p5..p26 dont exists on a nucleo. These names are only valid on the LPC1768 and LPC11U24 mbed. Check the pinout diagram for the nucleos to replace these pinnames by valid names for pins that support the required functions such as I2C or SPI.

posted by Wim Huiskamp 30 Dec 2014

Not sure what those would be it has Arduino headers. I'm just trying to learn and the Nucleo was one of the cheapest boards I could use on a Mac. If someone wouldn't mind taking a look and letting me know. In order for me to do much I need some way to see what is going on on the board and the LCD seems like the best way to output since there is no remote debugging available for any of the boards with a Mac. Nucleo complete pinout is ( http://developer.mbed.org/platforms/ST-Nucleo-F411RE/ ).

posted by Bryan McWhirt 30 Dec 2014

I updated the constructed default sub-class names, and forgot to change the default constructor names, sorry for the foo bar. Try copying the example again from the site, it should work now. Also, you probably need either, I2C or SPI, not both, so you can just comment out the one you don't need, and you'll need to use the correct pin names from your platform.

posted by Neal Horman 06 Jan 2015
5 years, 8 months ago.

There may be more issues, but the pinnames p5..p26 dont exists on a nucleo. These names are only valid on the LPC1768 and LPC11U24 mbed. soundcloud to mp3

9 years, 3 months ago.

Hi Roumen. I assume that you've solved this.

If you still need help, you need to paste a copy of the code, since it doesn't exactly match my sample. Make sure to surround it in "code" tags. see the "Editing tips" hyper link at the bottom of the answer text box.

Hi, Neal, Sorry I do not solve it yet.

I do the following:

1. Create new program in compiler

2. add mbed library

3. import Your Adafruit_GFX library

4. create main.cpp file

5. paste the code of Your Example

May be Adafruit_GFX need some additional library in order to work ?

Errors :

Error: Expected either a definition or a tag name in "main.cpp", Line: 19, Col: 7

Error: Expected a ")" in "main.cpp", Line: 22, Col: 5

Error: Expected a type specifier in "main.cpp", Line: 22, Col: 5

Error: Function returning function is not allowed in "main.cpp", Line: 22, Col: 10

Error: Expected a ";" in "main.cpp", Line: 22, Col: 51

Warning: Parsing restarts here after previous syntax error in "main.cpp", Line: 26, Col: 6

Error: Expected either a definition or a tag name in "main.cpp", Line: 30, Col: 7

Error: Expected a ")" in "main.cpp", Line: 33, Col: 5

Error: Expected a type specifier in "main.cpp", Line: 33, Col: 5

Error: Function returning function is not allowed in "main.cpp", Line: 33, Col: 10

Error: Expected a ";" in "main.cpp", Line: 33, Col: 36

Warning: Parsing restarts here after previous syntax error in "main.cpp", Line: 37, Col: 6

Error: Expected a ")" in "main.cpp", Line: 40, Col: 2

Error: Expected a type specifier in "main.cpp", Line: 40, Col: 2

Error: Explicit type is missing ("int" assumed) in "main.cpp", Line: 40, Col: 2

Error: "SPI_TypeDef" has already been declared in the current scope in "main.cpp", Line: 40, Col: 2

Error: Expected a "{" in "main.cpp", Line: 40, Col: 6

Warning: Parsing restarts here after previous syntax error in "main.cpp", Line: 47, Col: 2

Error: Identifier "gOled1" is undefined in "main.cpp", Line: 49, Col: 5

Error: Identifier "gOled2" is undefined in "main.cpp", Line: 50, Col: 5

/media/uploads/FuegoR/capture.png

posted by Roumen Likov 11 Dec 2014
9 years, 3 months ago.

Hi Roumen, the Problem is that your F302R8 platform has already used the names 'SPI2' and 'I2C2' for different definitions. The names in this sample are not so smart, so simply rename the subclasses to maybe 'mySPI' and 'myI2C' or something else.