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 7803645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:39:06+00:00 2026-06-02T01:39:06+00:00

I was investigating a compile and link issue within my program when I came

  • 0

I was investigating a compile and link issue within my program when I came across the following macro that was defined in a header and source file:

/* file_A.c */
#ifndef _NVSize    
   #define _NVSize 1
#endif

/* file_B.c */
#include "My_Header.h"
#ifndef _NVSize    
   #define _NVSize 1
#endif

/* My_Header.h */
#define _NVSize 1024

Nothing out of the ordinary yet, until I saw the following information in the GCC output map file:

/* My Map File */
...
.rodata  0x08015694   _NVSize
...

My understanding of the map file is that if you see a symbol in the .rodata section of the map file, this symbol is being treated as a global variable by the compiler. But, this shouldn’t be the case because macros should be handled by the preprocessor before the compiler even parses the file. This macro should be replaced with it’s defined value before compiling.

Is this the standard way that GCC handles macros or is there some implementation specific reason that GCC would treat this as a global (debug setting maybe)? Also, what does this mean if my macro gets redefined in a different source file? Did I just redefine it for a single source file or did I modify a global variable, thereby changing _NVSize everywhere it’s used within my program?

  • 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-06-02T01:39:08+00:00Added an answer on June 2, 2026 at 1:39 am

    I think the compiler is free to assign your macro to a global variable as long as it ensures that this produces the exact same result as if it did a textual replacement.

    During the compilation the compiler can mark this global specially to denote that it is a macro constant value, so no re-assignment is possible, no address can be taken, etc.

    If you redefine the macro in your sorce, the compiler might not perform this transformation (and treat it as you’d expect: a pre-compier textual replacement), perform it on one of the different values (or on all of them say, using different names for each occurrance), or do domething else 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While investigating an issue with application I'm working on, I've came across one behavior
I've been investigating this issue that only seems to get worse the more I
I have an issue with an open source C++ project that I have been
I have been investigating transactions and it appears that they take care of themselves
I am investigating a Java issue (using IBM JVM 1.4.2 64-bit) on Red Hat
While moving some code around for investigation purposes, I came across a little feature
Recently I came across some strange behaviour of my application. It has been developed
I am investigating a crash due to heap corruption. As this issue is non-trivial
Whilst 'investigating' finalisation (read: trying stupid things) I stumbled across some unexpected behaviour (to
Earlier today I asked this question . After spending some time investigating this issue,

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.