Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6670491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:16:32+00:00 2026-05-26T03:16:32+00:00

I have a problem with the #define in C I am using MSP430F5418 with

  • 0

I have a problem with the #define in C
I am using MSP430F5418 with IAR EW 5.10
I have a pragma called location which will put the next declaring variable to the specified segment.
In the below example a will put into the segment called myseg and b is not.

 #pragma location="myseg"
 static const char a[] = "amma";
 static const char b[] = "amrita";

I have a lot of constants like this.
I want to know whether I could do something like this…

#define TYPE location="myseg" \
       static const char 
#pragma TYPE a = "amma";
#pragma TYPE b = "amrita";
.....

so that I can avoid #pragma location="myseg" before each variable declaration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:16:33+00:00Added an answer on May 26, 2026 at 3:16 am

    You cannot use a #pragma inside a #define, nor the other way round.

    To circumvent this restriction, some compilers offer a _Pragma operator (GCC, LLVM) (__pragma in Visual C++) which provide the same functionality as the #pragma directive. This operator can be used in another macro. Find out whether your compiler supports such a pragma operator.

    Using this, you could write:

    #define DECLARE_IN_SEG(decl) \
        _Pragma(location="myseg") \
        static const char decl;
    
    DECLARE_IN_SEG(a = "amma");
    DECLARE_IN_SEG(b = "amrita");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with links testing locally using Apache with Windows. The final
I have a small problem with a define. I want to assign it to
I have a problem where I need to make a multi-colored wheel spin using
I follow your suggests by now I have another problem. ifndef MARKERCONTAINE_H define MARKERCONTAINE_H
I have a problem with the Enclojure REPL and using clojure modules from it.
Hello I have a problem to retrieve a value from a method. I'm using
I want to allow the user to define a query which will be used
Now I create a small PHP Application, here I have problem for using file
I would like to define tasks using NSDictionary, which I'd like to save in
I have a tinyMCE editor which uses the advanced theme. I am using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.