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 .ino expansion into .cpp messes up with namespaces (Read 2110 times)
Marc Jacobi
Junior Member
**
Offline


Posts: 28
Location: Netherlands
Joined: Feb 28th, 2012
.ino expansion into .cpp messes up with namespaces
Aug 30th, 2015 at 3:05pm
Print Post  
Found a problem with the use of namespaces.
Suppose I have a .ino that includes library files that use namespaces.

My .ino file
Code (C++)
Select All
#include "MyLibWithNamespace.h"

using namespace MyLibNamespace;

#include "SomeOtherInclude.h"


TypeFromMyLibWithNamespace MyMethodInIno()
{ ... }
...
 




File expanded into a .cpp that gets compiled
Code (C++)
Select All
#include "MyLibWithNamespace.h"

==>>#include "arduino.h"

TypeFromMyLibWithNamespace MyMethodInIno();
//
//<<==
using namespace MyLibNamespace;

#include "SomeOtherInclude.h"

...
 


==>> <<== marks the added code.

The resulting error is that the compiler cannot find 'TypeFromMyLibWithNamespace' because it was not fully qualified.

Quote:
error: 'TypeFromMyLibWithNamespace' does not name a type


Because this magic happens behind the scenes it reports the error on a line (of the .cpp) that makes no sense in the .ino - which took a long time to sort out.  Angry

EDIT:
Prefixing the full namespace before the returned type does not fix the problem!
The generated decalration does not copy them over.  Undecided


[2c]
Marc
« Last Edit: Aug 30th, 2015 at 3:11pm by Marc Jacobi »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12168
Location: United Kingdom
Joined: Apr 10th, 2010
Re: .ino expansion into .cpp messes up with namespaces
Reply #1 - Aug 30th, 2015 at 5:41pm
Print Post  
Hi,

Please test this in the Arduino it might be this is correct.

I think defs normally go in external .h to get around the design/issue

Also confirm which ide you are using.
« Last Edit: Aug 30th, 2015 at 5:42pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint