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 error __static_initialization_and_destruction_0 (Read 5039 times)
Henk Levels
Junior Member
**
Offline


Posts: 74
Joined: Sep 28th, 2015
error __static_initialization_and_destruction_0
Dec 10th, 2015 at 4:56pm
Print Post  
Hi,

I had a program that compiled well and moved some functions into a new class and header and cpp file.
When compiling I got the error __static_initialization_and_destruction_0
I did a rescan solution and was able to compile.
After closing Visual Studio and loading the project, again I got the compile error. A rescan solution did not help this time.
In the verbose message of the compiler the library which gives the error (Henk_Tally_LCD) is included. I also put compiler warnings on.
See screenshot for more info. How to solve this problem.
thanks
« Last Edit: Dec 10th, 2015 at 4:58pm by Henk Levels »  

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


Posts: 74
Joined: Sep 28th, 2015
Re: error __static_initialization_and_destruction_0
Reply #1 - Dec 10th, 2015 at 5:34pm
Print Post  
Hi Tim,

I swapped the intitialisation from the .h file to the .cpp file and made an extra function init where these variables are initialized.
However I still have the same error messaga even after Build - Clean.
I have another class Henk_Transmit (with .h and .cpp file) and initialize variables in the header file of that class but the compiler does not complain.
Any suggestion how to solve this?
  
Back to top
 
IP Logged
 
Serenifly
Junior Member
**
Offline


Posts: 20
Joined: Jun 20th, 2013
Re: error __static_initialization_and_destruction_0
Reply #2 - Dec 10th, 2015 at 7:59pm
Print Post  
This is not a compiler error, but a linker error. Post the relevant code. You likely mixed up something with the header and .cpp files. So something has been declared in the header, but wasn't properly defined.


And as your warning says, you can only initialize class members like this in C++11:
http://stackoverflow.com/questions/25773714/initialize-class-member-variables-in...
Might as well activate C++11

  
Back to top
 
IP Logged
 
Henk Levels
Junior Member
**
Offline


Posts: 74
Joined: Sep 28th, 2015
Re: error __static_initialization_and_destruction_0
Reply #3 - Dec 11th, 2015 at 8:48am
Print Post  
Hi, Serenifly, Tim

See code below.
When I comment out the constructor Tally compiling goes well (see screenshot below).

The two lines in the main code are.
- HenkLib_Transmit Henk_Trm;// declare Henk_Transmit to class HenkLib_Transmit
- Tally TallyF;// declare TallyF to class Tally

The screenshot attached is the header file.
Sorry but I could only attach 1 screen shot even when I select keep old file

Strange is that HenkLib_Transmit is build in the same way as class Tally and HenkLib_Transmit, does compile well.
Why does the constructor in class Tally give me this errorĀ  __static_initialization_and_destruction_0 when I remove the comment line ??
Please help
« Last Edit: Dec 11th, 2015 at 9:21am by Henk Levels »  

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: error __static_initialization_and_destruction_0
Reply #4 - Dec 15th, 2015 at 1:25pm
Print Post  
I think your best answers for Arduino code will come from the forum at arduino.cc

Visual Micro uses the same code so the Ide you are using does not prevent you from asking for help from the experts.

http://forum.arduino.cc/
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint