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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:37:15+00:00 2026-05-18T02:37:15+00:00

Several lines of code are worth a thousand words: I have three simple files:

  • 0

Several lines of code are worth a thousand words:

I have three simple files: header.h, main.cpp, other.cpp

==== CODE BEGIN ====

// header.h  
  #pragma once  

const void* p = 0;

// main.cpp

  #include "header.h"

int main()
{
    return 0;
}

// other.cpp

  #include "header.h"
==== CODE END ====

When compiling the simplest project, the VC++ 2010 complains as follows:

ClCompile:
  other.cpp
  main.cpp
  Generating Code...
other.obj : error LNK2005: "void const * const p" (?p@@3PBXB) already defined in main.obj
D:\Test\Debug\bug.exe : fatal error LNK1169: one or more multiply defined symbols found

Build FAILED.

Time Elapsed 00:00:00.29
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I am sure this is a bug of VC++ 2010, because of the following two references:

  1. The C++ standard says: (at page 140 of n3126)

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

  2. The MSDN says:

    “In C, constant values default to
    external linkage, so they can appear
    only in source files. In C++, constant
    values default to internal linkage,
    which allows them to appear in header
    files.

    The const keyword can also be used
    in pointer declarations.”

  • 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-18T02:37:15+00:00Added an answer on May 18, 2026 at 2:37 am

    const void *p = 0; defines p as a pointer to const void, but does not define p itself to be const at all. Since your p is not a const object, the rule giving it internal linkage does not apply, so it has external linkage.

    void *const p = 0; would define p as a const pointer. void const * const p would define p as a const pointer to const void.

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

Sidebar

Related Questions

Several lines of code are worth a thousand words: I have three simple files:
Hopefully a picture is worth a thousand lines of code because I don't want
Let's say I have several lines of code to clarify specific settings on a
Possible Duplicate: iif equivalent in c# I have several lines of code using IIf
/** Constant <code>IDX_USER=IDX_+ USER_ID</code> */ I have several lines of code which was generated
I have a string with several lines of CSS code. I want to match
I have several files containing this line Release: X I want to increment X
I have a ~23000 line SQL dump containing several databases worth of data. I
I have several log files of events (one event per line). The logs can
In our code base there are a few very long methods (several pages worth

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.