VS Arduino | |
Visual Micro >> General Board >> Problem with structures
https://www.visualmicro.com/forums/YaBB.pl?num=1562773407 Message started by Marius on Jul 10th, 2019 at 3:43pm |
Title: Problem with structures Post by Marius on Jul 10th, 2019 at 3:43pm
Hi
I declared a structure as folllows: Code (c++):
And get this error: Code (c++):
It worked before in other sketches but now I have an error. Not sure if I must set some parameter. |
Title: Re: Problem with structures Post by Visual Micro on Jul 10th, 2019 at 4:11pm
can you post a full ino
|
Title: Re: Problem with structures Post by Marius on Jul 11th, 2019 at 6:45am Code (c++):
|
Title: Re: Problem with structures Post by Visual Micro on Jul 11th, 2019 at 1:25pm
It has always been the case that you need to place your own prototypes between the creation of a type and where they are first used.
Arduino IDE has moved to using a new system to deduce the location of prototypes which works most of the time. We will shortly move to the same. The older system places them before first line of real code (non #include), which is why users types would always be placed in .h files. You can override by adding them yourself. Notice I have added prototypes for the save and load methods that make use of the types in their signatures. Code (c++):
|
Title: Re: Problem with structures Post by Marius on Jul 11th, 2019 at 1:49pm
That does not work either as you need the type declaration in the proto declaration.
Code (c++):
|
Title: Re: Problem with structures Post by Visual Micro on Jul 11th, 2019 at 2:01pm
Sorry I should have added the prototypes after the type had been created + there are some bugs in your code. One example is that you changed the type name from Config to ConfigObject but you have not changed the type name within the rest of the code.
I have used the original json example to show the prototypes in the correct location alongside code that works. Code (c++):
|
Title: Re: Problem with structures Post by Marius on Jul 11th, 2019 at 2:31pm
Thanks that works now. The bugs were me mucking about to try and isolate the issue
|
Title: Re: Problem with structures Post by Visual Micro on Jul 11th, 2019 at 2:39pm
Great, Yep makes sense. When/if you create a new empty project the template adds a note about the prototypes but we need to move to using the ctags system Arduino uses.
If Microsoft hasn't of caused tool window chaos with VS2019 we would be working on that right now :'( but the forward moves will be good for us :) |
VS Arduino » Powered by YaBB 2.6.12! YaBB Forum Software © 2000-2024. All Rights Reserved. |