g++

g++ error: expected ; before “it”

耗尽温柔 提交于 2020-01-03 05:28:07
问题 I'm porting C++ app from Solaris to Linux and I'm stuck with the following error. The code is: template <class MapSuperClass> class FWPointerMap : public MapSuperClass { public: FWPointerMap() { _wipe = false; } FWPointerMap(const MapSuperClass* mMap) { MapSuperClass::const_iterator it = mMap->begin(); // line 50 while(it != mMap->end()) { insert(MapSuperClass::value_type((*it).first, (*it).second)); it++; } _wipe = false; } And I get the following error: ../../framework/fwcore/hdr

C++ unordered_map using a custom class type as the key

ぃ、小莉子 提交于 2020-01-03 05:08:16
问题 I am trying to use a custom class as key for an unordered_map , like the following: #include <iostream> #include <algorithm> #include <unordered_map> using namespace std; class node; class Solution; class Node { public: int a; int b; int c; Node(){} Node(vector<int> v) { sort(v.begin(), v.end()); a = v[0]; b = v[1]; c = v[2]; } bool operator==(Node i) { if ( i.a==this->a && i.b==this->b &&i.c==this->c ) { return true; } else { return false; } } }; int main() { unordered_map<Node, int> m;

G++ always fails with undefined reference to _Unwind_GetIPInfo

与世无争的帅哥 提交于 2020-01-03 04:50:17
问题 I've just upgraded to Ubuntu 11.04 on my Asus EeePC netbook, and have a problem with G++. Compiling any program using G++, even a simple "Hello World", whether using iostream, cstdio, or stdio.h, fails with the message: /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/libstdc++.so: undefined reference to `_Unwind_GetIPInfo@GCC_4.2.0' collect2: ld returned 1 exit status I use Synaptic Package Manager. Before the upgrade, Ubuntu provided GCC 4.4, though I had also installed GCC 4.5 (gcc-4.5)

C++: linked library disappears and gives segfault during execution

丶灬走出姿态 提交于 2020-01-03 03:25:52
问题 I'm having a problem building a library. In the Makefile I tell g++ that I need tclstub8.6 by putting -ltclstub8.6 , and g++ takes it into account (sorry for these messages in French): make: AVERTISSEMENT : le fichier « ../Linux-PORT/i586-GCC4/Makefile » a une date de modification 609 s dans le futur *** Compile c [gcc] libtestGuiMnt_info.Linux-PORT.i586-GCC4.c *** Compile C++ [g++] mntdisplay.cc *** Compile C++ [g++] mntogl.cc mntogl.cc: In member function 'virtual int MNTOgl::Display()

How can I link against libpython.a such that the runtime linker can find all the symbols in libpython.a?

时光怂恿深爱的人放手 提交于 2020-01-03 01:40:11
问题 In a sequel question to this question, my corporate environment lacks the libpython2.6.so shared object but has the libpython2.6.a file. Is there a way that I can compile in libpython2.6.a while retaining the symbols in libpython2.6.a such that dynamic libraries can find these symbols at runtime? My current compile with the static library looks like: g++ -I/usr/CORP/pkgs/python/2.6.2/include/python2.6 \ ~/tmp.cpp -pthread -lm -ldl -lutil \ /usr/CORP/pkgs/python/2.6.2/lib/python2.6/config

App crashes on iOS 6: Symbol not found: ___sync_fetch_and_add_4

一曲冷凌霜 提交于 2020-01-02 15:53:07
问题 I have an application that works perfectly with iOS4 and iOS5. It uses a statically compiled version of the zeromq library, targeted for ARM. Apple denied my application because they claim it crashes under iOS 6 (yet unreleased..wth?) After trying it with the iOS 6 GM I can confirm it does crash when we initialize the ZeroMQ socket. Here is the crash messages: dyld: lazy symbol binding failed: Symbol not found: ___sync_fetch_and_add_4 Referenced from: /var/mobile/Applications/00EDEEDA-0068

Maps of maps allocated in shared memory

前提是你 提交于 2020-01-02 08:22:54
问题 Inside a boost::interprocess::managed_shared_memory , I am trying to create boost::unordered_map inside another boost::unordered_map as value, having key as std::string for both maps. This Map in Map inside a shared memory segment gets accessed by two different processes fetch values from both outer & inner maps. Below is my implementation & want to know if this is possible/right way or any other better way possible? boost::interprocess::managed_shared_memory segment(boost::interprocess::open

g++ can't find headers but I did include them

时光毁灭记忆、已成空白 提交于 2020-01-02 08:15:11
问题 I am starting on c++ and already going wrong ... I am trying to compile a small test of levelDB : #include <assert.h> #include "leveldb/db.h" using namespace std; int main() { leveldb::DB* db; leveldb::Options options; options.create_if_missing = true; leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db); assert(status.ok()); return 1; } Here is the g++ command : g++ -I include/ testLevelDB.cpp Output: /tmp/ccuBnfE7.o: In function `main': testLevelDB.cpp:(.text+0x14):

Initialization of member: bug in GCC or my thinking?

依然范特西╮ 提交于 2020-01-02 05:34:07
问题 I've got an enum type defined in the private section of my class. I have a member of this type defined as well. When I try to initialize this member in the constructor body, I get memory corruption problems at run-time. When I initialize it through an initialization list in the same constructor instead, I do not get memory corruption problems. Am I doing something wrong? I'll simplify the code, and if it is a GCC bug I'm sure that it's a combination of the specific classes I'm combining

lambda returns '1' all time

亡梦爱人 提交于 2020-01-02 04:45:11
问题 Have code like this #include <iostream> using namespace std; int main() { cout<<[](){ return 0;}; cout<<[](){ return 3.2;}; cout<<[](){ return true;}; cout<<[](){ return false;}; cout<<[](){ return "Hello world!";}; cout<<[]()->int{ return 0;}; cout<<[]()->double{ return 3.2;}; cout<<[]()->bool{ return true;}; cout<<[]()->bool{ return false;}; cout<<[]()->const char*{ return "Hello world!";}; return 0; } Compile it with gcc version 4.8.2 and my output is only 1111111111 . Why only "1"? 回答1: