• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA C++ code format in SDK

Messages
43
Country
us-ohio
I am looking at the sample code in the SDK and curious about the structure of the code.

Here is the code as written in SDK.Temperature.cpp

Code:
GAUGE_HEADER_FS700(GAUGE_W, temperature_gauge_name, &temperature_list, \
                        temperature_mouse_rect, 0, 0, 0, 0);

The format for this is defined in gauges.h as

Code:
#define GAUGE_HEADER_FS700(             \
                default_size_mm,        \
                gauge_name,             \
                element_list,           \
                pmouse_rect,            \
                pgauge_callback,        \
                user_data,              \
                parameters,             \
                usage)                  \
        GAUGE_HEADER_FS800(             \
                GAUGEHDR_VAR_NAME,      \
                default_size_mm,        \
                gauge_name,             \
                element_list,           \
                pmouse_rect,            \
                pgauge_callback,        \
                user_data,              \
                usage)

My question is related to the escape character "\" at the end of almost every line.

Is that escaping out the return character in the editor?

Is the original code the same as this

Code:
GAUGE_HEADER_FS700(                            \
                    GAUGE_W,                \
                    temperature_gauge_name, \
                    &temperature_list,        \
                    temperature_mouse_rect, \
                    0, \
                    0, \
                    0, \
                    0 \
                    );

And is it necessary to do that at all since this seems to build without an issue. Although I have not tried the resulting gauge.

Code:
GAUGE_HEADER_FS700(
                    GAUGE_W,               
                    temperature_gauge_name,
                    &temperature_list,       
                    temperature_mouse_rect,
                    0,
                    0,
                    0,
                    0
                    );

For me my brain processes this structure better than the one line method and I curious if the escapes are necessary.
 
Adding to this question. If you look at the reset of the code on the page you don't see anymore escapes on the page.

Code:
FAILURE_RECORD    temperature_fail[] =
{
    {FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_NO_DRAW},
    {FAIL_NONE, FAIL_ACTION_NONE}
};

Which begs the question why in is it there in GAUGE_HEADER_FS700 sections?
 
I would guess the \ has to do with the creation of the macro and is unrelated to what you would want to do. The Gauges.h is just a file that has to be included...messing with the stuff in there isn't a good idea.

You should be able to set up your Gauge header the way you have done and compile it without any problem. Here is my gauge header (using the Gauge header FS1000 though) for one of my gauges in the Milviz F-4.

Code:
GAUGE_HEADER_FS1000(
    GAUGEHDR_VAR_NAME,
    GAUGE_W,
    sv_gauge_name,
    &sv_element_list,
    sv_mouse_rect,
    &SV,
    0, 0,
    gauge_guid3,
    0,     0,     0,     0,     0);
 
The \ character allows multiple lines of input to be interpreted as a single line of code.
I expect it's use in gauges.h is a holdover from much earlier versions. Current versions of the MS C compiler are pretty forgiving about line breaks within code.

Doug
 
Back
Top