Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Does not name a type in a. cpp file (Read 2318 times)
Llombard
Newbies
*
Offline


Posts: 3
Joined: Jan 15th, 2019
Does not name a type in a. cpp file
Jan 15th, 2019 at 12:33pm
Print Post  
Hello from Germany,

I am a new Member and I think I have a very simple question (for experts), but I searched in the internet for hours and could not find a solution.

In the past I used only .ino sketches and they worked good. Now I try to add .cpp and .h files to my M5 project and  I received an error.

Example:

I tried to use the statement ,M5.Lcd.init(), in the .cpp file and I also added the include statement <M5Stack.h> in the .cpp file but I got this error message.

‘M5’ does not name a type
    M5.Lcd.init()
Error compiling project sources 

What have I to do, that the compiler knows instructions from other library’s ?


An example would be helpful for me to understand the right syntax.
Uwe
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Does not name a type in a. cpp file
Reply #1 - Jan 15th, 2019 at 1:27pm
Print Post  
is vMicro>Compiler>Depp search switched on?

Does a simple project compile when using .ino and the include for M5Stack.h?
  
Back to top
WWW  
IP Logged
 
Llombard
Newbies
*
Offline


Posts: 3
Joined: Jan 15th, 2019
Re: Does not name a type in a. cpp file
Reply #2 - Jan 15th, 2019 at 1:56pm
Print Post  
Thank you for your answer.

- Deep search for Libraries is on
- the simple .ino projekt with an # include .... and an M5.Lcd.... statement is running

When I add code ( empty arduino .cpp and .h) and I put a ,M5. ....., Statement in the .cpp file it is marked in red an the I receive the error.

The #include statement will not produce an error.

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Does not name a type in a. cpp file
Reply #3 - Jan 15th, 2019 at 2:00pm
Print Post  
A build is required to detect new libs in cpp files.

Pleases switch on vmicro>compiler> "verbose" and also "show build properties" then build and post the output as a .txt file.

Confirm you have #included your .h in the .ino file and in the .cpp
  
Back to top
WWW  
IP Logged
 
Llombard
Newbies
*
Offline


Posts: 3
Joined: Jan 15th, 2019
Re: Does not name a type in a. cpp file
Reply #4 - Jan 15th, 2019 at 2:17pm
Print Post  
I solved the error.

After I have restarted the computer , not only Visual Studio, the Error is gone. I have no idea why, but it worked and that is the main point.

Thanks for your quick help . Five Stars for your service !
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint