#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;









1















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










share|improve this question



















  • 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

















1















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










share|improve this question



















  • 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













1












1








1








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










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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











  • 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












  • 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







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












1 Answer
1






active

oldest

votes


















0
















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






share|improve this answer


























    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
    );



    );














    draft saved

    draft discarded
















    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









    0
















    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






    share|improve this answer





























      0
















      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






      share|improve this answer



























        0














        0










        0









        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






        share|improve this answer













        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 21:02









        user3629249user3629249

        12.2k1 gold badge11 silver badges16 bronze badges




        12.2k1 gold badge11 silver badges16 bronze badges

































            draft saved

            draft discarded















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현