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
Hot Topic (More than 8 Replies) "Serial" is undefined (Read 26797 times)
bitNine
Junior Member
**
Offline


Posts: 13
Joined: Oct 2nd, 2015
"Serial" is undefined
Oct 2nd, 2015 at 9:19pm
Print Post  
I'm very new to Arduino, but not new to VS. Having a problem getting a sketch I wrote in the Arduino IDE to work within VS with the VM plugin.

Error: identifier "Serial" is undefined

Looking at the error list, I can see that there's a bunch of errors from Arduino.h and USBAPI.h that it can't find avr/pgmspace.h and a few other files. 

I even started a completely fresh project, but it doesn't like "Serial". It also compiles just fine and uploads ok. I'm sure there's a simple explanation for this one...

Running VS 2015 on Win10
« Last Edit: Oct 2nd, 2015 at 9:19pm by bitNine »  
Back to top
 
IP Logged
 
bitNine
Junior Member
**
Offline


Posts: 13
Joined: Oct 2nd, 2015
Re: "Serial" is undefined
Reply #1 - Oct 2nd, 2015 at 9:36pm
Print Post  
Here's a screenshot
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12192
Location: United Kingdom
Joined: Apr 10th, 2010
Re: "Serial" is undefined
Reply #2 - Oct 2nd, 2015 at 10:27pm
Print Post  
Hi,

Thanks for the image.

If you change the tool bar from x86 to Win32 I think the intellisense will work.

Historically we use Win32 C++ project for Arduino but Visual Studio 2015 seems to switch some projects to other platforms such as x64 or x86. You are the 2nd person to report this so it will be investigated as to how this happens so a solution can be implemented.
  
Back to top
IP Logged
 
bitNine
Junior Member
**
Offline


Posts: 13
Joined: Oct 2nd, 2015
Re: "Serial" is undefined
Reply #3 - Oct 2nd, 2015 at 10:40pm
Print Post  
There's no Win32 option. Just x86 and x64. Adding Win32 and setting platform to ARM didn't make a difference. Also identical issue in Release and Debug
« Last Edit: Oct 2nd, 2015 at 10:40pm by bitNine »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12192
Location: United Kingdom
Joined: Apr 10th, 2010
Re: "Serial" is undefined
Reply #4 - Oct 2nd, 2015 at 10:56pm
Print Post  
Hi, sounds like your visual studio c++ isn't installed properly and I guess you also do not have File>New>Project>C++>Win32 Project? 

Can you please run the "Custom" option in the vs installer via control panel and ensure that c++ is installed??

A screen shot of your current installer options would also be useful so I can try to replicate what you have and have not enabled.

Thanks
« Last Edit: Oct 2nd, 2015 at 10:57pm by Tim@Visual Micro »  
Back to top
IP Logged
 
bitNine
Junior Member
**
Offline


Posts: 13
Joined: Oct 2nd, 2015
Re: "Serial" is undefined
Reply #5 - Oct 3rd, 2015 at 2:41am
Print Post  
The C++ Win32 project is definitely there. I have done a bit of tinkering with C++ in the past, so it's always there, though C# is my primary language used in VS.

Looks like all options are installed. The only thing C++ related that is NOT installed are the mobile development libraries.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
bitNine
Junior Member
**
Offline


Posts: 13
Joined: Oct 2nd, 2015
Re: "Serial" is undefined
Reply #6 - Oct 3rd, 2015 at 2:53am
Print Post  
After a reboot, I opened up VS to check the intellisense stuff, and now it says it can't find Arduino.h, nor DHT.h, which is included as a header file in the project. Build still works ok though. So I tinkered around with the configuration, and it wasn't until I switched back to x86 that it was ok with the DHT.h lib. Then I went back in and edited the Win32 configuration I added, and changed platform from ARM to Win32, and that also worked for DHT.h, but still the same on the Serial call. I also noticed that a call to analogRead() throws another error, as seen here.

I even tried running VS in administrator mode.

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
bitNine
Junior Member
**
Offline


Posts: 13
Joined: Oct 2nd, 2015
Re: "Serial" is undefined
Reply #7 - Oct 3rd, 2015 at 3:28am
Print Post  
Just a bit more info... All this earlier work was on my work computer, but that might be moot. It's got VS 2010, 2013, and 2015 on it.

I just installed on my home computer, which is a fresh install of Win10, fresh install of VS2015, and of course the arduino plugin install. Same results. No Win32 build config, with errors on Serial and analogRead().

I removed C++ libs from VS, so I could reinstall them, and I tried to create a new project without them, to see the behavior. It results in a "parameter incorrect" error with HRESULT 0x80070057. I then reinstalled the C++ libs, but it did not change anything.

Let me know what other info I can provide  Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12192
Location: United Kingdom
Joined: Apr 10th, 2010
Re: "Serial" is undefined
Reply #8 - Oct 3rd, 2015 at 3:46pm
Print Post  
Hi,

I think I might have found the problem.

Are you launching Visual Studio 2015 or Visual Studio with Blend? Maybe look for a different shortcut to launch Visual Studio?

I found this article:-

http://stackoverflow.com/questions/32345925/how-come-c-project-in-visual-studio-...

By the way: On my VS I currently only have the C++ Common Tools installed. The others are optional but not required. However the ability to create a Win32 C++ program is required. Earlier Visual Studio versions included Win32 C++ by default but in Vs2015 it is optional.
« Last Edit: Oct 3rd, 2015 at 3:49pm by Tim@Visual Micro »  
Back to top
IP Logged
 
bitNine
Junior Member
**
Offline


Posts: 13
Joined: Oct 2nd, 2015
Re: "Serial" is undefined
Reply #9 - Oct 3rd, 2015 at 4:57pm
Print Post  
I've never used blend, so definitely not launching it with the blend shortcut.

I am certain the problem lies in the errors that it cannot find pgmspace.h, io.h and interrupt.h. What is so weird about this is that when it sows the error that it can't find the file from the include within arduino.h, and I double-click the error, it opens arduino.h, then the errors disappear from the list and it shows the error coming from USBAPI.h. After moving around a bit, the error from arduino.h shows up again.

I also just noticed that I am running IDE version 1.7.7, but 1.7 isn't an IDE choice. I downloaded that from arduino.org, not arduino.cc. After installing 1.6.5 from arduino.cc, it seems that it has solved the problem. I guess I don't understand the difference between arduino.org and arduino.cc, and why the arduino.org version number is higher. It wasn't until I was looking at the screen for configuring IDE locations, that I clicked the Download/Install IDE button and got to the arduino.cc download page.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12192
Location: United Kingdom
Joined: Apr 10th, 2010
Re: "Serial" is undefined
Reply #10 - Oct 3rd, 2015 at 6:15pm
Print Post  
Thanks for the info. I'll give arduino.org a try sometime. They did confuse things by taking an early version of the arduino ide and giving it a higher version number. 

It screws things up at my end because Visual Micro has to auto detect the Arduino version and apply different rules to mimic the various versions. It's easier for Arduino.cc and .org because each .exe only does things one way, their way Smiley
  
Back to top
IP Logged
 
esiner
Newbies
*
Offline


Posts: 1
Joined: Oct 22nd, 2015
Re: "Serial" is undefined
Reply #11 - Oct 22nd, 2015 at 1:42am
Print Post  
I had the same error, nothing seemed to work.
Switching the board to something else (i.e Mega) fixed the problem, even after switching back to Uno.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12192
Location: United Kingdom
Joined: Apr 10th, 2010
Re: "Serial" is undefined
Reply #12 - Oct 22nd, 2015 at 1:51am
Print Post  
Thanks, yes switching boards can sometimes refresh the intellisense.

However there was a problem with arduino.org when used with the Visual Micro 1.6 option. Arduino.org is really arduino 1.5

A new release of visual micro has just been published that shows the configuration difference between arduino.cc and arduino.org more clearly. The new release also includes official support for arduino.org which improves intellisense with 32 bit boards such as Zero and Due
  
Back to top
IP Logged
 
ThinhT
Newbies
*
Offline


Posts: 4
Joined: Jan 27th, 2017
Re: "Serial" is undefined
Reply #13 - Jan 28th, 2017 at 8:45am
Print Post  
Hi, I also have this problem. 
When I first create an Arduino project, everything work fine. But then after I close the project and visual studio. When next time I open the project again, it shows theses errors and can not complied.
I'm installed the latest visual micro that I downloaded from visual studio online shop.
  
Back to top
 
IP Logged
 
ThinhT
Newbies
*
Offline


Posts: 4
Joined: Jan 27th, 2017
Re: "Serial" is undefined
Reply #14 - Jan 28th, 2017 at 9:09am
Print Post  
http://forum.arduino.cc/index.php?topic=274996.0
I think I have similar problem as this guy as well
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12192
Location: United Kingdom
Joined: Apr 10th, 2010
Re: "Serial" is undefined
Reply #15 - Jan 28th, 2017 at 1:14pm
Print Post  
Hi,

The problem above is that the use says he is running arduino.org 1.7 but has selected Arduino.cc 1.6 in visual micro. This is an old post pre arduino 1.8 ide where the two comes joined together again.

Can you please create a new thread in this forum and post info about your visual studio and arduino versions.

Then switch on vmicro>compiler>verbose and also "vmicro>compiler>show build properties", then build and post the output as a .txt file or email to info[at]visualmicro.com

Thanks
  
Back to top
IP Logged
 
ThinhT
Newbies
*
Offline


Posts: 4
Joined: Jan 27th, 2017
Re: "Serial" is undefined
Reply #16 - Jan 29th, 2017 at 4:15am
Print Post  
I got it working fine now after following your instruction from another post. (which is rename "Sketch" to "NameOfProject"). I overlooked this problem even though I see many other answers of yours keep telling people to make sure the files has the same name. Until I see the screenshot picture one of the guy posted. http://www.visualmicro.com/forums/YaBB.pl?num=1485456165

Thanks for your time and quick reply. And great work.
« Last Edit: Jan 29th, 2017 at 4:20am by ThinhT »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12192
Location: United Kingdom
Joined: Apr 10th, 2010
Re: "Serial" is undefined
Reply #17 - Jan 29th, 2017 at 12:11pm
Print Post  
Thanks.

I have been trying to hard to reproduce the issue. Any guide you can give to reproducing how you ended up with a project of a different name?

What did you click to create the project?
Did the new project land with the different project name?
Did you close the project after creation without saving changes?

I think questions like these will help me understand how this can happen


  
Back to top
IP Logged
 
ThinhT
Newbies
*
Offline


Posts: 4
Joined: Jan 27th, 2017
Re: "Serial" is undefined
Reply #18 - Feb 2nd, 2017 at 1:40am
Print Post  
I created the project from : vMicro/New Arduino Project
and typed in the name.

I notice the project have the same name when I first created and even after close and reopen visual studio. However, when I shut down my computer and turn visual studio on after, then reopen the arduino project. Then the name of the project automatically changed to "Sketch" , which I need to rename it again.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12192
Location: United Kingdom
Joined: Apr 10th, 2010
Re: "Serial" is undefined
Reply #19 - Feb 3rd, 2017 at 1:08am
Print Post  
Thanks

I replicated the problem by creating a project and then closing it (or the ide) but I clicked "No" to save ".vcxfilter" changes when prompted.

The next release auto saves the project after it has been created so that this can't happen anymore.

Thanks again for the report.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint