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

  • Home
  • SEARCH
  • 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 4550966
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:34:12+00:00 2026-05-21T16:34:12+00:00

I have a global unique value, which I wish to use it across within

  • 0

I have a global unique value, which I wish to use it across within a exe and different DLLs.

For any project which wish to use it, they may just include defs.h

I was wondering, should I declare it as

// defs.h
const UINT UNIQUE_MESSAGE = 
    RegisterWindowMessage(_T("UNIQUE_MESSAGE-{E5476FDB-3E7E-4113-8132-1D87709BC46C}"));

OR

// defs.h
const static UINT UNIQUE_MESSAGE = 
    RegisterWindowMessage(_T("UNIQUE_MESSAGE-{E5476FDB-3E7E-4113-8132-1D87709BC46C}"));

Currently, I do not find any different from code consumer point of view. Is there any catch behind? Should I use static or not?

  • 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-21T16:34:12+00:00Added an answer on May 21, 2026 at 4:34 pm

    In C++, namespace level const are implicitly static (i.e it has internal linkage), unless you write extern const. So both of your syntax is basically same.

    §7.1.1/6 says,

    Objects declared const and not explicitly declared extern have internal linkage.

    So I would suggest this: (with minimal consideration, like excluding static initialization order fiasco and many other issues with static and global variables)

    //in defs.h:
    extern const UINT UNIQUE_MESSAGE;
    
    //defs.cpp
    const UINT UNIQUE_MESSAGE =  RegisterWindowMessage(_T("whatever"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

VB 6.0 does not have any global handler.To catch runtime errors,we need to add
I have a python module that makes use of a huge dictionary global variable,
I am trying to design header only library, which unfortunately needs to have global
I have a server, which uses a global variable to store the next available
I don't have a Global Application class code-behind any more inside my installed templates.
I have some global variables in a Python script. Some functions in that script
Hey right now I'm using jQuery and I have some global variables to hold
I have defined the global nls_date_format on Oracle 10.2 XE as follows: alter system
I have used a static global variable and a static volatile variable in file
I have the following in my Global.asax.cs routes.MapRoute( Arrival, {partnerID}, new { controller =

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.