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 Problem with Serial.begin in c/h file (Read 5369 times)
sysshad80
Newbies
*
Offline


Posts: 7
Joined: Jan 29th, 2015
Problem with Serial.begin in c/h file
Feb 16th, 2015 at 9:48am
Print Post  
Hi,
I have a project with a main.ino file that is trying to include some old regular C files ive made (with Add|Add new C item)   myUart.c and myUART.h

In the .h file i have
void myUartInit();

In the .c file i have
void myUartInit()
{
Serial.begin(57600);
}

and when i in my .ino file call the myUartInit() i get 
error: 'Serial' undeclared (first use in this function)
and i have #include "myUart.h" in the ino file!

i have tried to include following libraries in myUart.c without success, i only get more errors
#include <MinimumSerial.h>
#include <USBAPI.h>
#include <HardwareSerial.h>

Any suggestion on what im doing wrong, many thanks in advance. I really would like to have the old AVR studio 4 layout of splitted files in this manner.
« Last Edit: Feb 16th, 2015 at 9:49am by sysshad80 »  
Back to top
 
IP Logged
 
sysshad80
Newbies
*
Offline


Posts: 7
Joined: Jan 29th, 2015
Re: Problem with Serial.begin in c/h file
Reply #1 - Feb 16th, 2015 at 10:01am
Print Post  
Hmm it just hit me...
Maybe those .c/.h files cant add Serial.begin which i presume come from the c++ world?

Is it better ot have several ino files, or should i try to make cpp files instead ?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problem with Serial.begin in c/h file
Reply #2 - Feb 16th, 2015 at 11:31am
Print Post  
You are right the .c files are not where you want to be.

It's up to you if you use .ino or cpp. 

.ino is easier for some people because prototypes are made automatically and all code/vars/functions/includes are shared between all .ino files. 

Thanks
  
Back to top
IP Logged
 
sysshad80
Newbies
*
Offline


Posts: 7
Joined: Jan 29th, 2015
Re: Problem with Serial.begin in c/h file
Reply #3 - Feb 16th, 2015 at 12:05pm
Print Post  
Ok thanks for your reply Smiley
And i really like visual micro, keep up the good work.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint