g++

passing ‘const this argument discards qualifiers [-fpermissive]

一世执手 提交于 2019-12-18 12:06:20
问题 I have a class Cache which has a function write specified as bool write(const MemoryAccess &memory_access, CacheLine &cl); I am calling this function like this. const Cache *this_cache; c = (a==b)?my_cache:not_cache; c->write(memory_access,cl); The above line is giving me following error "passing ‘const Cache’ as ‘this’ argument of ‘bool Cache::write(const MemoryAccess&, CacheLine&)’ discards qualifiers [-fpermissive]." the this argument is compiler specific which helps in code-mangling and

Using clang++, -fvisibility=hidden, and typeinfo, and type-erasure

妖精的绣舞 提交于 2019-12-18 11:25:58
问题 This is a scaled down version of a problem I am facing with clang++ on Mac OS X. This was seriously edited to better reflect the genuine problem (the first attempt to describe the issue was not exhibiting the problem). The failure I have this big piece of software in C++ with a large set of symbols in the object files, so I'm using -fvisibility=hidden to keep my symbol tables small. It is well known that in such a case one must pay extra attention to the vtables, and I suppose I face this

g++ compiler flag to minimize binary size

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 10:56:10
问题 I'm have an Arduino Uno R3. I'm making logical objects for each of my sensors using C++. The Arduino has very limited on-board memory 32KB*, and, on average, my compiled objects are coming out around 6KB*. I am already using the smallest possible data types required, in an attempt to minimize my memory footprint. Is there a compiler flag to minimize the size of the binary, or do I need to use shorter variable and function names, less functions, etc. to minimize my code base? Also, any other

Difference between <cstring> and <string>

不想你离开。 提交于 2019-12-18 10:05:18
问题 Earlier today (actually yesterday due to my time-zone) I was attempting a programming interview using Visual Studio 2012 for C++ on Interview Street (which uses g++ ). To be brief, I came across several compilation errors 1 when I was using #include <cstring> which was provided by the skeleton code in one of the question, and after turning to #include <string> all compilation errors magically disappeared. However, upon submission to Interview Street, I had to add c back; otherwise I got

gcc warning" 'will be initialized after'

隐身守侯 提交于 2019-12-18 09:56:27
问题 I am getting a lot of these warnings from 3rd party code that I cannot modify. Is there a way to disable this warning or at least disable it for certain areas (like #pragma push/pop in VC++)? Example: list.h:1122: warning: `list<LogOutput*, allocator<LogOutput*> >::node_alloc_' will be initialized after list.h:1117: warning: `allocator<LogOutput*> list<LogOutput*, allocator<LogOutput*> >::alloc_' 回答1: Make sure the members appear in the initializer list in the same order as they appear in the

pack fold expression (c++17 extension) available when building with c++14

不问归期 提交于 2019-12-18 09:08:50
问题 The following code contains a fold expression, which afaiu is a c++17 feature: template <typename... T> static bool variable_length_or(const T ... v) { return (v || ...); } bool foo () { return variable_length_or(true, false, true, false); } what I find odd is that both g++ and clang++ seem to be fine with it when building with -std=c++14 (compiler-explorer). They do create a warning: <source>:2:16: warning: pack fold expression is a C++17 extension [-Wc++17-extensions] return (v || ...);

Cant insert to std::map (G++)

為{幸葍}努か 提交于 2019-12-18 09:06:26
问题 I have a following trouble: struct ServerPP { std::string name; int id; int expires; }; std::map<std::string, std::set<ServerPP>> RemindTable; int test(std::string email, ServerPP serv) { RemindTable[email].insert(serv); // error when compile in this row below } Error in g++: In file included from /usr/include/c++/4.4/string:50, from /usr/include/c++/4.4/bits/locale_classes.h:42, from /usr/include/c++/4.4/bits/ios_base.h:43, from /usr/include/c++/4.4/ios:43, from /usr/include/c++/4.4/istream

Cant insert to std::map (G++)

╄→尐↘猪︶ㄣ 提交于 2019-12-18 09:06:12
问题 I have a following trouble: struct ServerPP { std::string name; int id; int expires; }; std::map<std::string, std::set<ServerPP>> RemindTable; int test(std::string email, ServerPP serv) { RemindTable[email].insert(serv); // error when compile in this row below } Error in g++: In file included from /usr/include/c++/4.4/string:50, from /usr/include/c++/4.4/bits/locale_classes.h:42, from /usr/include/c++/4.4/bits/ios_base.h:43, from /usr/include/c++/4.4/ios:43, from /usr/include/c++/4.4/istream

g++ Linker errors after upgrading to gcc-4.8 on Debian, libc6

拟墨画扇 提交于 2019-12-18 08:56:24
问题 I have just dist-upgraded a Debian Weezy machine to run gcc-4.8 from gcc-4.7. Previously the build environment was sane and was compiling normally. Now it gives the following linker errors, with any program (even a trivial hello world): /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug

g++ Linker errors after upgrading to gcc-4.8 on Debian, libc6

六眼飞鱼酱① 提交于 2019-12-18 08:56:01
问题 I have just dist-upgraded a Debian Weezy machine to run gcc-4.8 from gcc-4.7. Previously the build environment was sane and was compiling normally. Now it gives the following linker errors, with any program (even a trivial hello world): /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug