Go Down

Topic: SerialPort.h and "Serial" (Read 618 times) previous topic - next topic

pito

Sep 18, 2013, 07:56 pm Last Edit: Sep 18, 2013, 08:13 pm by pito Reason: 1
What should be done in order to be able to name the new SerialPort (by fat16lib) class "Serial" (thus replace the old Serial automatically)?
Code: [Select]
SerialPort<0, 63, 63> Serial;

I've been trying to replace the standard Serial.print() with ie. NewSerial.print()
Code: [Select]
SerialPort<0, 63, 63> NewSerial;

but it seems to me it is almost impossible in practice. When replacing it in main I am getting zillion vector errors as it messes with all possible includes where the standard "Serial." is used..  :smiley-roll:

fat16lib

It is not possible to declare the name "Serial" since that will conflict with the symbol declared in HardwareSerial.

I use the following declaration and macro in sketches to minimize changes.
Code: [Select]

SerialPort<0, 63, 63> NewSerial;
#define Serial NewSerial


Serial must not be used in any libraries or HardwareSerial will be linked and a conflict will happen.

pito


Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview