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 Compiler issue I haven't see since 1978 (Read 1991 times)
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Compiler issue I haven't see since 1978
May 20th, 2018 at 6:42pm
Print Post  
Something changed recently that impacts the way the C++ compiler processes my code. Here is an abstract of what I am seeing:

void A () {
  B();
}

void B () {
}

Compile error because B hasn't been defined yet when called by A.

I saw this issue in 1978 when I joined Tandem Computers and started writing in TAL (Tandem's Assembly Language). It required that all referenced code be defined before being called. This forced a discipline to the code such that I could count on the beginning of the program to be the very last function in the code.

I am seeing this pattern in my own code and wondering if this is a switch setting that I inadvertently checked or something else. I can provide details if that will help.

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler issue I haven't see since 1978
Reply #1 - May 20th, 2018 at 9:26pm
Print Post  
Hi Bob

If you were using a standard cpp file you would have needed to define a prototype to ensure B is defined before it is referenced.

With .ino we try to automatically insert the prototypes but its' not an exact science and depending on the code above the methods and the order things are defined it can be right or wrong.

The safest way is to define the prototypes yourself in your code at the location that makes sense. ensure the exact same signature as the function

In the "work in progress" download there is a new example project that demonstrates this. Also demonstrates an easier way to work with local libraries. ("file>new>project>c++>arduino project with local library")

Code (C++)
Select All
//define user types


//define c++ protoypes
void A();
void B();

//define methods

void A() {
  B();
}

void B() {
}

 

« Last Edit: May 20th, 2018 at 9:29pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: Compiler issue I haven't see since 1978
Reply #2 - May 20th, 2018 at 10:30pm
Print Post  
Thanks, Tim. That makes lots of sense. My code was in a .ino file while it was being developed. I will move it into a class. And in fact, I think it may be a good candidate to test your local library concept. I will let you know how it works out.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler issue I haven't see since 1978
Reply #3 - May 20th, 2018 at 10:31pm
Print Post  
Thanks v much
  
Back to top
WWW  
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: Compiler issue I haven't see since 1978
Reply #4 - May 21st, 2018 at 3:40am
Print Post  
Tim,

I converted my HC05 AT Utility program to your structure. It took me about an hour. It would go a lot faster if I didn't create Library1 or if I knew how to rename it. 

What I am puzzled by is that I don't understand what I just read about the intention of this new capability. I am developing a program that will have at least three instantiations under different names like "Commander", "Signaler" and "Motor Manager". In each case, the only thing different between the three programs will be the content of "Robot.h". 

The discovery you shared with me about using Add Reference meant that I can work on the same class library in all three programs. By putting all of the classes I am developing in the libraries folder, I can have three instances of Visual Studio open (right now I have 5!) and each can be editing the same file. 

The way I read the description of this capability, it sounds like the intention is to share the same code with multiple sketches... just what I am doing; however it is not at all clear to me how this is supposed to happen.

So two questions: 
1) Is the approach I am currently using viable... optimal?
2) What am I missing about the new approach?

Bob

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compiler issue I haven't see since 1978
Reply #5 - May 21st, 2018 at 11:50am
Print Post  
For that you just need to use a shared project. I only mentioned local libraries because in the zip example you provided previously you have created shared projects/libraries but below a sketch.

I suggest you keep your shared projects in folders above or as siblings to your project(s), not below individual projects.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint