g++

Multiplying matrices: error: expected primary-expression before 'struct'

五迷三道 提交于 2019-12-13 08:26:21
问题 I am trying to write a program that is supposed to multiply matrices using threads. I am supposed to fill the matrices using random numbers in a thread. I am compiling in g++ and using PTHREADS. I have also created a struct to pass the data from my command line input to the thread so it can generate the matrix of random numbers. The sizes of the two matrices are also passed in the command line as well. I keep getting: main.cpp:7: error: expected primary-expression before 'struct' my code @

Differences with IDE/compilers array handling [duplicate]

我们两清 提交于 2019-12-13 08:04:35
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: C/C++: Array size at run time w/o dynamic allocation is allowed? I'm in a class where we have a simple assignment to write a function that returns a pointer to a dynamic array and provide a stub to test it. I have this done so I'm not asking for help with the assignment. On the class blog another student suggests that it is intuitive that one should be able to do int Array[size]; where size is apparently a user

g++ Undefined Symbol Error using shared library

不想你离开。 提交于 2019-12-13 07:51:14
问题 The symbol is in the file. I verified it using nm & grep but I still get the undefined symbol error when I run the compiled application. Other symbols in the shared library are working just fine. The header file declares it as extern and it is not in a conditional pre-processor block. I'm new to c/c++ so any experience with something like this would be appreciated. There are a ton of related questions on StackOverflow, but everyone is listing source files and headers that don't mean anything

C++ GL linker undefined reference

我的未来我决定 提交于 2019-12-13 07:18:02
问题 Using Ubuntu 14.04, g++, I want to port a project from make to cmake. Getting the following error when I sudo make install . Linking CXX executable texmapper /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../.. /lib/libplibssg.a(ssgLeaf.o): undefined reference to symbol 'glNewList' /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libGL.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status A linker error like many encountered on

gcc workaround while using shared_ptr to insert in std::set

一个人想着一个人 提交于 2019-12-13 06:43:11
问题 This code fails to compile using g++ 4.2.1 but works fine under vc++ v8. #include <set> typedef std::set<int *> IntPtrSet; IntPtrSet iptrSet; typedef std::set<shared_ptr<int>> IntPtrSet2; IntPtrSet2 iptrSet2; void AddIntegers(int& x) { iptrSet.insert(&x); iptrSet2.insert(&x); } shared_ptr is similar to boost::shared_ptr or tr1::shared_ptr. It emits the following errors, No matching function for call to std::allocator<shared_ptr<int>>::construct(int**, const shared_ptr<int>&) No matching

Array trait causes template argument deduction failure

强颜欢笑 提交于 2019-12-13 06:21:50
问题 The following code does not compile with G++ (although I believe it should): #include <iostream> template <unsigned N> struct foo_traits { typedef const char ArrayArg[N]; typedef int Function (ArrayArg *); }; template <unsigned N> int foo (typename foo_traits<N>::Function *ptr) { return ptr(&"good"); } int bar (const char (*x)[5]) { std::cout << *x << "\n"; return 0; } int main () { return foo(bar); } I checked this with GCC 4.4 through 4.7, and I get a template argument deduction failure.

Why my dev-c++ “can't open output file”?

こ雲淡風輕ζ 提交于 2019-12-13 05:34:19
问题 When I re-complied a .cpp file after crashing, my compiler told me this. g:/program files (x86)/dev-cpp/mingw64/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot open output file C:\Users\chanson\Desktop\quickSort.exe: Permission denied collect2.exe: error: ld returned 1 exit status Compilation failed after 1.00 seconds with errors My system is win8.1, compiler is TDM-GCC 4.8.1 64-bit Release. I think it's the problem of my OS, but how can I fix this problem? Thanks a lot!

undefined reference when linking V8

人走茶凉 提交于 2019-12-13 05:27:51
问题 I'm strugling to compile a really small example with V8.. cpp program is this: #include "v8.h" int main() { v8::HandleScope handle_scope; return 0; } Compile line: g++ -I/home/lterje/git/tengine/Externals/v8/include /home/lterje/git/tengine/Externals/v8/out/ia32.release/obj.target/tools/gyp/libv8_snapshot.a test.cpp -o test -lpthread Error I'm getting: /tmp/ccHYtJuE.o: In function `main': test.cpp:(.text+0x11): undefined reference to `v8::HandleScope::HandleScope()' test.cpp:(.text+0x22):

VC++ function string::c_str(): the address of the first byte was set to 0 (compare to g++)

為{幸葍}努か 提交于 2019-12-13 05:21:31
问题 I met a strange problem when trying to get the result of a string’s function c_str() whose result is inconsistent with g++. There is a function called Test to return a string instance. And I want to use a char* type to store the result (it’s needed). As you can see the function is simple return a string “resultstring”. But when I try to get the result something strange happened. The result I got is “” in part two. The part one and part three both return the “resultstring”. While that’s in

Explicit template specialization in g++ causing troubles

北战南征 提交于 2019-12-13 05:18:32
问题 I've got the problem converting this piece of code to g++ from MSVC: #include <unordered_map> class A { template <class T> class B; template<> class A::B<int> { }; std::unordered_map<int, long, B<int>> m_Map; }; Sure thing this is not standard c++, while VS still allows it GCC (g++) throws an error "Explicit specialization in non-namespace scope". Now I make it c++ compliant following the reference http://en.cppreference.com/w/cpp/language/template_specialization: #include <unordered_map>