predefined Variables Arduino IDE

IDE gerelateerde berichten
Gebruikers-avatar
Berichten: 212
Geregistreerd: 03 Sep 2013, 10:03
Woonplaats: Katwijk ZH

predefined Variables Arduino IDE

Berichtdoor baco1978 » 01 Jul 2024, 17:22

Er zijn blijkbaar vooraf gedefinieerde variabelen te gebruiken in de Arduino IDE

zoals:
__DATE__); // compilation date
__TIME__); // compilation time

Deze kwam ik vandaag tegen:
(__VERSION__); // gcc version
(__FILE__); // file compiled

en Onderstaande laat de IDE versie zien:
String stringOne = String(ARDUINO, DEC);
Serial.println(stringOne); // arduino ide version


zijn er nog meer van dit soort variabelen te vinden/beschikbaar ?
ik heb geprobeerd met google te zoeken maar daar werd ik niet veel wijzer van.

misschien dat iemand nog een paar leuke/handige eheft om te delen
Met vriendelijke groet Arjan

Advertisement

Berichten: 89
Geregistreerd: 02 Nov 2022, 13:03

Re: predefined Variables Arduino IDE

Berichtdoor ThHe » 03 Jul 2024, 20:54

In dit rijtje hoort ook __LINE__ die het programma line nummer geeft.

Berichten: 4085
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: predefined Variables Arduino IDE

Berichtdoor shooter » 04 Jul 2024, 10:36

Standard predefined macros

The compiler supports these predefined macros specified by the ISO C99, C11, C17, and ISO C++17 standards.

__cplusplus Defined as an integer literal value when the translation unit is compiled as C++. Otherwise, undefined.

__DATE__ The compilation date of the current source file. The date is a constant length string literal of the form Mmm dd yyyy. The month name Mmm is the same as the abbreviated month name generated by the C Runtime Library (CRT) asctime function. The first character of date dd is a space if the value is less than 10. This macro is always defined.

__FILE__ The name of the current source file. __FILE__ expands to a character string literal. To ensure that the full path to the file is displayed, use /FC (Full Path of Source Code File in Diagnostics). This macro is always defined.

__LINE__ Defined as the integer line number in the current source file. The value of this macro can be changed by using a #line directive. The integral type of the value of __LINE__ can vary depending on context. This macro is always defined.

__STDC__ Defined as 1 when compiled as C and if the /Za compiler option is specified. Starting in Visual Studio 2022 version 17.2, it's defined as 1 when compiled as C and if the /std:c11 or /std:c17 compiler option is specified. Otherwise, undefined.

__STDC_HOSTED__ Defined as 1 if the implementation is a hosted implementation, one that supports the entire required standard library. Otherwise, defined as 0.

__STDC_NO_ATOMICS__ Defined as 1 if the implementation doesn't support optional standard atomics. The MSVC implementation defines it as 1 when compiled as C and one of the /std C11 or C17 options is specified.

__STDC_NO_COMPLEX__ Defined as 1 if the implementation doesn't support optional standard complex numbers. The MSVC implementation defines it as 1 when compiled as C and one of the /std C11 or C17 options is specified.

__STDC_NO_THREADS__ Defined as 1 if the implementation doesn't support optional standard threads. The MSVC implementation defines it as 1 when compiled as C and one of the /std C11 or C17 options is specified.

__STDC_NO_VLA__ Defined as 1 if the implementation doesn't support standard variable length arrays. The MSVC implementation defines it as 1 when compiled as C and one of the /std C11 or C17 options is specified.

__STDC_VERSION__ Defined when compiled as C and one of the /std C11 or C17 options is specified. It expands to 201112L for /std:c11, and 201710L for /std:c17.

__STDCPP_DEFAULT_NEW_ALIGNMENT__ When /std:c17 or later is specified, this macro expands to a size_t literal that has the value of the alignment guaranteed by a call to alignment-unaware operator new. Larger alignments are passed to an alignment-aware overload, such as operator new(std::size_t, std::align_val_t). For more information, see /Zc:alignedNew (C++17 over-aligned allocation).

__STDCPP_THREADS__ Defined as 1 if and only if a program can have more than one thread of execution, and compiled as C++. Otherwise, undefined.

__TIME__ The time of translation of the preprocessed translation unit. The time is a character string literal of the form hh:mm:ss, the same as the time returned by the CRT asctime function. This macro is always defined.
paul deelen
shooter@home.nl

Terug naar Arduino IDE

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 4 gasten