Upgrading to C++17 — error: ‘__BEGIN_NAMESPACE_STD’ does not name a typehow to enable __BEGIN_NAMESPACE_STD in stdlib.hWhat does the explicit keyword mean?Do the parentheses after the type name make a difference with new?Compiling C++11 with g++error while working with boost::sregex_token_iteratorDoes std::vector<Object> reserve method need a copy constructor for Object class?Invalid use of incomplete type struct std::hash with unordered_map with std::pair of enum class as keyWhat are the new features in C++17?Compiler requesting c++17 support to be enabled for std::variant by using the -std++17 flag when -std=c++17 is in compiler outputSetup Clang on Travis CI for C++17How to fix overloading operands +?

Can the Supreme Court overturn an impeachment?

What's the difference between 違法 and 不法?

How to color a curve

Can a significant change in incentives void an employment contract?

How do I extrude a face to a single vertex

Did arcade monitors have same pixel aspect ratio as TV sets?

Drawing a topological "handle" with Tikz

How will losing mobility of one hand affect my career as a programmer?

How to align and center standalone amsmath equations?

Find last 3 digits of this monster number

Do Legal Documents Require Signing In Standard Pen Colors?

Is camera lens focus an exact point or a range?

THT: What is a squared annular “ring”?

Do the concepts of IP address and network interface not belong to the same layer?

Should I install hardwood flooring or cabinets first?

Difference between -| and |- in TikZ

What is this type of notehead called?

Translation of Scottish 16th century church stained glass

Some numbers are more equivalent than others

Why has "pence" been used in this sentence, not "pences"?

How can "mimic phobia" be cured or prevented?

Can I sign legal documents with a smiley face?

When quoting, must I also copy hyphens used to divide words that continue on the next line?

Is there a word to describe the feeling of being transfixed out of horror?



Upgrading to C++17 — error: ‘__BEGIN_NAMESPACE_STD’ does not name a type


how to enable __BEGIN_NAMESPACE_STD in stdlib.hWhat does the explicit keyword mean?Do the parentheses after the type name make a difference with new?Compiling C++11 with g++error while working with boost::sregex_token_iteratorDoes std::vector<Object> reserve method need a copy constructor for Object class?Invalid use of incomplete type struct std::hash with unordered_map with std::pair of enum class as keyWhat are the new features in C++17?Compiler requesting c++17 support to be enabled for std::variant by using the -std++17 flag when -std=c++17 is in compiler outputSetup Clang on Travis CI for C++17How to fix overloading operands +?













6















I'm trying to upgrade an application to C++17 and am getting the following compiler error:



error: ‘__BEGIN_NAMESPACE_STD’ does not name a type


I'm using gcc (GCC) 8.2.0 and compiling with the following command:



g++ -std=c++17 variant.cpp -o variant


Here's a small test program:



#include <iostream>
#include <variant>

using v_t = std::variant<int, double>;

int main(int argc, char const* argv[])

v_t foo = 5;
printf("foo contains %dn", *std::get_if<int>(&foo));

std::cout << "Success" << std::endl;
return 0;



And here's the error I get (below). Note that how to enable __BEGIN_NAMESPACE_STD in stdlib.h discusses a similar issue but the proposed solution (include C++ headers, not C headers such as stdlib.h) is something I'm already doing.



I am able to get this code compiling on my OSX laptop, possibly because I have a newer libc installed by default. However, when I run on my linux machine I get these errors. On the Linux machine, I am using the following linker/glibc version: ldd (Ubuntu EGLIBC 2.19-0ubuntu6.14) 2.19



I'm continuing to debug this but would appreciate any pointers in the right direction.



In file included from /toolchains/gcc-8.2.0/include/c++/8.2.0/cstdlib:75,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ext/string_conversions.h:41,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/basic_string.h:6391,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/string:52,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/locale_classes.h:40,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/ios_base.h:41,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ios:42,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ostream:38,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/iostream:39,
from variant.cpp:1:
/usr/include/stdlib.h:95:1: error: ‘__BEGIN_NAMESPACE_STD’ does not name a type
__BEGIN_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:101:5: error: ‘div_t’ does not name a type; did you mean ‘pid_t’?
} div_t;
^~~~~
pid_t
/usr/include/stdlib.h:112:1: error: ‘__END_NAMESPACE_STD’ does not name a type
__END_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:121:5: error: ‘lldiv_t’ does not name a type; did you mean ‘ldiv_t’?
} lldiv_t;
^~~~~~~









share|improve this question



















  • 3





    This is not about libc, but libstdc++. Presumably the alternative toolchain was not installed correctly or correctly activated, and installed headers leak into the compilation. Check the use of your -I or -isystem flags. It could also be helpful to look at g++ -E output to determine which files were included from where.

    – Florian Weimer
    Mar 21 at 13:49











  • Thanks, @FlorianWeimer -- you are correct. This was an issue with a broken gcc build. I recompiled from scratch and everything just worked.

    – Kulluk007
    Mar 21 at 15:31















6















I'm trying to upgrade an application to C++17 and am getting the following compiler error:



error: ‘__BEGIN_NAMESPACE_STD’ does not name a type


I'm using gcc (GCC) 8.2.0 and compiling with the following command:



g++ -std=c++17 variant.cpp -o variant


Here's a small test program:



#include <iostream>
#include <variant>

using v_t = std::variant<int, double>;

int main(int argc, char const* argv[])

v_t foo = 5;
printf("foo contains %dn", *std::get_if<int>(&foo));

std::cout << "Success" << std::endl;
return 0;



And here's the error I get (below). Note that how to enable __BEGIN_NAMESPACE_STD in stdlib.h discusses a similar issue but the proposed solution (include C++ headers, not C headers such as stdlib.h) is something I'm already doing.



I am able to get this code compiling on my OSX laptop, possibly because I have a newer libc installed by default. However, when I run on my linux machine I get these errors. On the Linux machine, I am using the following linker/glibc version: ldd (Ubuntu EGLIBC 2.19-0ubuntu6.14) 2.19



I'm continuing to debug this but would appreciate any pointers in the right direction.



In file included from /toolchains/gcc-8.2.0/include/c++/8.2.0/cstdlib:75,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ext/string_conversions.h:41,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/basic_string.h:6391,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/string:52,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/locale_classes.h:40,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/ios_base.h:41,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ios:42,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ostream:38,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/iostream:39,
from variant.cpp:1:
/usr/include/stdlib.h:95:1: error: ‘__BEGIN_NAMESPACE_STD’ does not name a type
__BEGIN_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:101:5: error: ‘div_t’ does not name a type; did you mean ‘pid_t’?
} div_t;
^~~~~
pid_t
/usr/include/stdlib.h:112:1: error: ‘__END_NAMESPACE_STD’ does not name a type
__END_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:121:5: error: ‘lldiv_t’ does not name a type; did you mean ‘ldiv_t’?
} lldiv_t;
^~~~~~~









share|improve this question



















  • 3





    This is not about libc, but libstdc++. Presumably the alternative toolchain was not installed correctly or correctly activated, and installed headers leak into the compilation. Check the use of your -I or -isystem flags. It could also be helpful to look at g++ -E output to determine which files were included from where.

    – Florian Weimer
    Mar 21 at 13:49











  • Thanks, @FlorianWeimer -- you are correct. This was an issue with a broken gcc build. I recompiled from scratch and everything just worked.

    – Kulluk007
    Mar 21 at 15:31













6












6








6








I'm trying to upgrade an application to C++17 and am getting the following compiler error:



error: ‘__BEGIN_NAMESPACE_STD’ does not name a type


I'm using gcc (GCC) 8.2.0 and compiling with the following command:



g++ -std=c++17 variant.cpp -o variant


Here's a small test program:



#include <iostream>
#include <variant>

using v_t = std::variant<int, double>;

int main(int argc, char const* argv[])

v_t foo = 5;
printf("foo contains %dn", *std::get_if<int>(&foo));

std::cout << "Success" << std::endl;
return 0;



And here's the error I get (below). Note that how to enable __BEGIN_NAMESPACE_STD in stdlib.h discusses a similar issue but the proposed solution (include C++ headers, not C headers such as stdlib.h) is something I'm already doing.



I am able to get this code compiling on my OSX laptop, possibly because I have a newer libc installed by default. However, when I run on my linux machine I get these errors. On the Linux machine, I am using the following linker/glibc version: ldd (Ubuntu EGLIBC 2.19-0ubuntu6.14) 2.19



I'm continuing to debug this but would appreciate any pointers in the right direction.



In file included from /toolchains/gcc-8.2.0/include/c++/8.2.0/cstdlib:75,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ext/string_conversions.h:41,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/basic_string.h:6391,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/string:52,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/locale_classes.h:40,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/ios_base.h:41,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ios:42,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ostream:38,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/iostream:39,
from variant.cpp:1:
/usr/include/stdlib.h:95:1: error: ‘__BEGIN_NAMESPACE_STD’ does not name a type
__BEGIN_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:101:5: error: ‘div_t’ does not name a type; did you mean ‘pid_t’?
} div_t;
^~~~~
pid_t
/usr/include/stdlib.h:112:1: error: ‘__END_NAMESPACE_STD’ does not name a type
__END_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:121:5: error: ‘lldiv_t’ does not name a type; did you mean ‘ldiv_t’?
} lldiv_t;
^~~~~~~









share|improve this question
















I'm trying to upgrade an application to C++17 and am getting the following compiler error:



error: ‘__BEGIN_NAMESPACE_STD’ does not name a type


I'm using gcc (GCC) 8.2.0 and compiling with the following command:



g++ -std=c++17 variant.cpp -o variant


Here's a small test program:



#include <iostream>
#include <variant>

using v_t = std::variant<int, double>;

int main(int argc, char const* argv[])

v_t foo = 5;
printf("foo contains %dn", *std::get_if<int>(&foo));

std::cout << "Success" << std::endl;
return 0;



And here's the error I get (below). Note that how to enable __BEGIN_NAMESPACE_STD in stdlib.h discusses a similar issue but the proposed solution (include C++ headers, not C headers such as stdlib.h) is something I'm already doing.



I am able to get this code compiling on my OSX laptop, possibly because I have a newer libc installed by default. However, when I run on my linux machine I get these errors. On the Linux machine, I am using the following linker/glibc version: ldd (Ubuntu EGLIBC 2.19-0ubuntu6.14) 2.19



I'm continuing to debug this but would appreciate any pointers in the right direction.



In file included from /toolchains/gcc-8.2.0/include/c++/8.2.0/cstdlib:75,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ext/string_conversions.h:41,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/basic_string.h:6391,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/string:52,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/locale_classes.h:40,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/bits/ios_base.h:41,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ios:42,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/ostream:38,
from /toolchains/gcc-8.2.0/include/c++/8.2.0/iostream:39,
from variant.cpp:1:
/usr/include/stdlib.h:95:1: error: ‘__BEGIN_NAMESPACE_STD’ does not name a type
__BEGIN_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:101:5: error: ‘div_t’ does not name a type; did you mean ‘pid_t’?
} div_t;
^~~~~
pid_t
/usr/include/stdlib.h:112:1: error: ‘__END_NAMESPACE_STD’ does not name a type
__END_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:121:5: error: ‘lldiv_t’ does not name a type; did you mean ‘ldiv_t’?
} lldiv_t;
^~~~~~~






c++ c++17 libstdc++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 13:47









Florian Weimer

17.9k31148




17.9k31148










asked Mar 21 at 13:43









Kulluk007Kulluk007

151213




151213







  • 3





    This is not about libc, but libstdc++. Presumably the alternative toolchain was not installed correctly or correctly activated, and installed headers leak into the compilation. Check the use of your -I or -isystem flags. It could also be helpful to look at g++ -E output to determine which files were included from where.

    – Florian Weimer
    Mar 21 at 13:49











  • Thanks, @FlorianWeimer -- you are correct. This was an issue with a broken gcc build. I recompiled from scratch and everything just worked.

    – Kulluk007
    Mar 21 at 15:31












  • 3





    This is not about libc, but libstdc++. Presumably the alternative toolchain was not installed correctly or correctly activated, and installed headers leak into the compilation. Check the use of your -I or -isystem flags. It could also be helpful to look at g++ -E output to determine which files were included from where.

    – Florian Weimer
    Mar 21 at 13:49











  • Thanks, @FlorianWeimer -- you are correct. This was an issue with a broken gcc build. I recompiled from scratch and everything just worked.

    – Kulluk007
    Mar 21 at 15:31







3




3





This is not about libc, but libstdc++. Presumably the alternative toolchain was not installed correctly or correctly activated, and installed headers leak into the compilation. Check the use of your -I or -isystem flags. It could also be helpful to look at g++ -E output to determine which files were included from where.

– Florian Weimer
Mar 21 at 13:49





This is not about libc, but libstdc++. Presumably the alternative toolchain was not installed correctly or correctly activated, and installed headers leak into the compilation. Check the use of your -I or -isystem flags. It could also be helpful to look at g++ -E output to determine which files were included from where.

– Florian Weimer
Mar 21 at 13:49













Thanks, @FlorianWeimer -- you are correct. This was an issue with a broken gcc build. I recompiled from scratch and everything just worked.

– Kulluk007
Mar 21 at 15:31





Thanks, @FlorianWeimer -- you are correct. This was an issue with a broken gcc build. I recompiled from scratch and everything just worked.

– Kulluk007
Mar 21 at 15:31












0






active

oldest

votes











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/3.0/"u003ecc by-sa 3.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%2f55281832%2fupgrading-to-c17-error-begin-namespace-std-does-not-name-a-type%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















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%2f55281832%2fupgrading-to-c17-error-begin-namespace-std-does-not-name-a-type%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

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?