#if define string comparison for preprocessor directiveDifference between InvariantCulture and Ordinal string comparisonWhy is 'this' a pointer and not a reference?Improve INSERT-per-second performance of SQLite?Concatenate int to string using C PreprocessorWhen to use references vs. pointersGLSL preprocessorWhy does the C preprocessor interpret the word “linux” as the constant “1”?C/C++ preprocessor directive for handing compilation errorsHow does the C preprocessor handle circular dependencies?Get options used for compilation with preprocessor directives
Sending mail to the Professor for PhD, after seeing his tweet
Did the Soviet army intentionally send troops (e.g. penal battalions) running over minefields?
Would an object shot from earth fall into the sun?
Is there a pattern for handling conflicting function parameters?
Can I bring this power bank on board the aircraft?
What is the logical distinction between “the same” and “equal to?”
Principled construction of the quaternions
Booting Ubuntu from USB drive on MSI motherboard -- EVERYTHING fails
Why does it seem the best way to make a living is to invest in real estate?
Avoiding dust scattering when you drill
What "level" is a monster, for the Tough feat?
Airport Security - advanced check, 4th amendment breach
Confusion regarding control system of Mars Rover?
How to interpret the challenge rating of creatures?
Does the 'java' command compile Java programs?
Should I be an author on another PhD student's paper if I went to their meetings and gave advice?
Why most footers have a background color as a divider of section?
How do we know neutrons have no charge?
Everyone Gets a Window Seat
Why the first octet of a MAC address always end with a binary 0?
Job interview by video at home and privacy concerns
Does the US Armed Forces refuse to recruit anyone with an IQ less than 83?
Shell Sort, Insertion Sort, Bubble Sort, Selection Sort Algorithms (Python)
The answer is a girl's name (my future granddaughter) - can anyone help?
#if define string comparison for preprocessor directive
Difference between InvariantCulture and Ordinal string comparisonWhy is 'this' a pointer and not a reference?Improve INSERT-per-second performance of SQLite?Concatenate int to string using C PreprocessorWhen to use references vs. pointersGLSL preprocessorWhy does the C preprocessor interpret the word “linux” as the constant “1”?C/C++ preprocessor directive for handing compilation errorsHow does the C preprocessor handle circular dependencies?Get options used for compilation with preprocessor directives
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I'm trying to define an array with preprocessor directives to have variable size. This array is filled depending of #define :
#define PORTA (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT PORTA
#define EXP_GPIO0_PIN 0
I want to fill the array with :
const uint8_t PortAGpiosPortpinUsed[] =
#if EXP_GPIO0_PORT == PORTA
EXP_GPIO0_PIN,
#endif
As PORTA is a pointer, the compiler (GCC) doesn't allow this preprocessor syntax. Is there any solution to get it working ?
Thanks
Syl
c pointers directive string-comparison preprocessor
add a comment
|
I'm trying to define an array with preprocessor directives to have variable size. This array is filled depending of #define :
#define PORTA (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT PORTA
#define EXP_GPIO0_PIN 0
I want to fill the array with :
const uint8_t PortAGpiosPortpinUsed[] =
#if EXP_GPIO0_PORT == PORTA
EXP_GPIO0_PIN,
#endif
As PORTA is a pointer, the compiler (GCC) doesn't allow this preprocessor syntax. Is there any solution to get it working ?
Thanks
Syl
c pointers directive string-comparison preprocessor
1
Not sure what you are trying to do, but you should understand that preprocessor work is done before compilation or run time, so no compile or run time information is available to it.
– Eugene Sh.
Mar 28 at 20:14
1
The preprocessor doesn't work like that. Either have another macro (#define EXP_GPIO0_PORT_IS_PORTA 1
, otherwise undefiend) or do it at runtime
– Artyer
Mar 28 at 20:14
ifPORTA
is defined by another macro as an integer it works... preprocessor can only compare integers.
– Jean-François Fabre♦
Mar 28 at 20:24
can't compare two constants that are equal in preprocessor ? all expressions are constants. "PORTA" in that case is just a constant address. Both sides are same expression. Can't be at runtime, I need to optimize it as much as possible and preferably scalable...
– Wormzy
Mar 28 at 20:26
add a comment
|
I'm trying to define an array with preprocessor directives to have variable size. This array is filled depending of #define :
#define PORTA (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT PORTA
#define EXP_GPIO0_PIN 0
I want to fill the array with :
const uint8_t PortAGpiosPortpinUsed[] =
#if EXP_GPIO0_PORT == PORTA
EXP_GPIO0_PIN,
#endif
As PORTA is a pointer, the compiler (GCC) doesn't allow this preprocessor syntax. Is there any solution to get it working ?
Thanks
Syl
c pointers directive string-comparison preprocessor
I'm trying to define an array with preprocessor directives to have variable size. This array is filled depending of #define :
#define PORTA (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT PORTA
#define EXP_GPIO0_PIN 0
I want to fill the array with :
const uint8_t PortAGpiosPortpinUsed[] =
#if EXP_GPIO0_PORT == PORTA
EXP_GPIO0_PIN,
#endif
As PORTA is a pointer, the compiler (GCC) doesn't allow this preprocessor syntax. Is there any solution to get it working ?
Thanks
Syl
c pointers directive string-comparison preprocessor
c pointers directive string-comparison preprocessor
asked Mar 28 at 20:11
WormzyWormzy
91 bronze badge
91 bronze badge
1
Not sure what you are trying to do, but you should understand that preprocessor work is done before compilation or run time, so no compile or run time information is available to it.
– Eugene Sh.
Mar 28 at 20:14
1
The preprocessor doesn't work like that. Either have another macro (#define EXP_GPIO0_PORT_IS_PORTA 1
, otherwise undefiend) or do it at runtime
– Artyer
Mar 28 at 20:14
ifPORTA
is defined by another macro as an integer it works... preprocessor can only compare integers.
– Jean-François Fabre♦
Mar 28 at 20:24
can't compare two constants that are equal in preprocessor ? all expressions are constants. "PORTA" in that case is just a constant address. Both sides are same expression. Can't be at runtime, I need to optimize it as much as possible and preferably scalable...
– Wormzy
Mar 28 at 20:26
add a comment
|
1
Not sure what you are trying to do, but you should understand that preprocessor work is done before compilation or run time, so no compile or run time information is available to it.
– Eugene Sh.
Mar 28 at 20:14
1
The preprocessor doesn't work like that. Either have another macro (#define EXP_GPIO0_PORT_IS_PORTA 1
, otherwise undefiend) or do it at runtime
– Artyer
Mar 28 at 20:14
ifPORTA
is defined by another macro as an integer it works... preprocessor can only compare integers.
– Jean-François Fabre♦
Mar 28 at 20:24
can't compare two constants that are equal in preprocessor ? all expressions are constants. "PORTA" in that case is just a constant address. Both sides are same expression. Can't be at runtime, I need to optimize it as much as possible and preferably scalable...
– Wormzy
Mar 28 at 20:26
1
1
Not sure what you are trying to do, but you should understand that preprocessor work is done before compilation or run time, so no compile or run time information is available to it.
– Eugene Sh.
Mar 28 at 20:14
Not sure what you are trying to do, but you should understand that preprocessor work is done before compilation or run time, so no compile or run time information is available to it.
– Eugene Sh.
Mar 28 at 20:14
1
1
The preprocessor doesn't work like that. Either have another macro (
#define EXP_GPIO0_PORT_IS_PORTA 1
, otherwise undefiend) or do it at runtime– Artyer
Mar 28 at 20:14
The preprocessor doesn't work like that. Either have another macro (
#define EXP_GPIO0_PORT_IS_PORTA 1
, otherwise undefiend) or do it at runtime– Artyer
Mar 28 at 20:14
if
PORTA
is defined by another macro as an integer it works... preprocessor can only compare integers.– Jean-François Fabre♦
Mar 28 at 20:24
if
PORTA
is defined by another macro as an integer it works... preprocessor can only compare integers.– Jean-François Fabre♦
Mar 28 at 20:24
can't compare two constants that are equal in preprocessor ? all expressions are constants. "PORTA" in that case is just a constant address. Both sides are same expression. Can't be at runtime, I need to optimize it as much as possible and preferably scalable...
– Wormzy
Mar 28 at 20:26
can't compare two constants that are equal in preprocessor ? all expressions are constants. "PORTA" in that case is just a constant address. Both sides are same expression. Can't be at runtime, I need to optimize it as much as possible and preferably scalable...
– Wormzy
Mar 28 at 20:26
add a comment
|
1 Answer
1
active
oldest
votes
Perhaps something like this would work:
#ifdef PORTA
#define ADDRESS (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT ADDRESS
#define EXP_GPIO0_PIN 0
#endif
const uint8_t PortAGpiosPortpinUsed[] =
#ifdef PORTA
EXP_GPIO0_PIN,
#endif
Of course this expects that PORTA
is previously defined
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406110%2fif-define-string-comparison-for-preprocessor-directive%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Perhaps something like this would work:
#ifdef PORTA
#define ADDRESS (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT ADDRESS
#define EXP_GPIO0_PIN 0
#endif
const uint8_t PortAGpiosPortpinUsed[] =
#ifdef PORTA
EXP_GPIO0_PIN,
#endif
Of course this expects that PORTA
is previously defined
add a comment
|
Perhaps something like this would work:
#ifdef PORTA
#define ADDRESS (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT ADDRESS
#define EXP_GPIO0_PIN 0
#endif
const uint8_t PortAGpiosPortpinUsed[] =
#ifdef PORTA
EXP_GPIO0_PIN,
#endif
Of course this expects that PORTA
is previously defined
add a comment
|
Perhaps something like this would work:
#ifdef PORTA
#define ADDRESS (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT ADDRESS
#define EXP_GPIO0_PIN 0
#endif
const uint8_t PortAGpiosPortpinUsed[] =
#ifdef PORTA
EXP_GPIO0_PIN,
#endif
Of course this expects that PORTA
is previously defined
Perhaps something like this would work:
#ifdef PORTA
#define ADDRESS (*(PORT_t *) 0x0400)
#define EXP_GPIO0_PORT ADDRESS
#define EXP_GPIO0_PIN 0
#endif
const uint8_t PortAGpiosPortpinUsed[] =
#ifdef PORTA
EXP_GPIO0_PIN,
#endif
Of course this expects that PORTA
is previously defined
answered Mar 28 at 21:02
user3629249user3629249
12.2k1 gold badge11 silver badges16 bronze badges
12.2k1 gold badge11 silver badges16 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406110%2fif-define-string-comparison-for-preprocessor-directive%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Not sure what you are trying to do, but you should understand that preprocessor work is done before compilation or run time, so no compile or run time information is available to it.
– Eugene Sh.
Mar 28 at 20:14
1
The preprocessor doesn't work like that. Either have another macro (
#define EXP_GPIO0_PORT_IS_PORTA 1
, otherwise undefiend) or do it at runtime– Artyer
Mar 28 at 20:14
if
PORTA
is defined by another macro as an integer it works... preprocessor can only compare integers.– Jean-François Fabre♦
Mar 28 at 20:24
can't compare two constants that are equal in preprocessor ? all expressions are constants. "PORTA" in that case is just a constant address. Both sides are same expression. Can't be at runtime, I need to optimize it as much as possible and preferably scalable...
– Wormzy
Mar 28 at 20:26