g++

g++ compile error .h file

∥☆過路亽.° 提交于 2019-12-12 03:05:15
问题 I'm trying to compile a .cpp file using g++ in Linux Ubuntu 10.10 and when i try to compile this code #include <iostream> #include <vector> #include <"writeVector.h" #include <"insertionSort.h"> using namespace std; int main() { int n; int i; vector<int> V; cout << "Enter the amount of numbers you want to evaluate: "; cin >> n; cout << "Enter your numbers to be evaluated: " << endl; while (V.size() < n && cin >> i){ V.push_back(i); } InsertionSort(V); write_vector(V); return 0; } I have both

gcc gdb no debugging info

血红的双手。 提交于 2019-12-12 02:59:44
问题 I'm trying to prevent g++ from inlining templated functions, which cause gdb to lack debugging information, like local variables or even current line numbers. Actually, I'm guessing this is something related to inlining template functions, because this is the only situation where I can't have access to anything in my callstack. I've pretty much tried everything I could in g++ options, such as: -DDEBUG -O0 -fno-inline -fno-implicit-inline-templates and even considered prefixing my functions

How to directly access a certain part of a text file in g++?

送分小仙女□ 提交于 2019-12-12 02:39:15
问题 I have a text file containing a number of records. Each record is stored on a single line that is 100 characters long. Let's say I want to directly access the nth record. I could do it using a for loop, reading in n lines until I get to the record. But how could I access it directly? 回答1: If the each line is exactly 100 characters long and the line ending is always \n (i.e. no \r\n stuff) and there's no blank lines and people won't use 1 tab for 8 spaces etc. you can use (with ifstream) fin

Checking header file for dependencies at compile-time

孤街醉人 提交于 2019-12-12 02:30:06
问题 Do compilers offer the capability to automatically check if each source file (and its associated header file, if any) include all other headers that are required? Or at least issue a warning, say, if a required header is not included explicitly? For example, I would like the compiler to report when I do something like this: header1.h #include <string> ... header2.h #include "header1.h" #include <iostream> std::string blah; //<-- issue warning here, <string> not included explicitly ... source2

Typeinfo for ocl::CRException

落花浮王杯 提交于 2019-12-12 02:24:16
问题 I tried to run my C++ program using g++ but am getting following exception: "typeinfo for ocl::CRException" am using ocl namespace containing CRException class.. Please, help me on this. Here is the code where am including OCL classes : #ifndef VOIDSOFT_ADA2_LIND_HH #define VOIDSOFT_ADA2_LIND_HH #include <string> #include <list> #include <queue> #include <map> #include <ocl.h> #include "threaded.hh" using namespace std; using namespace ocl; class circuit; class Lind: public Threaded { public:

Different results VS C++ and GNU g++

ぃ、小莉子 提交于 2019-12-12 01:58:42
问题 I have a program that works in VS C++ and does not work with g++. Here is the code: #define _USE_MATH_DEFINES #include <cmath> #include <iostream> #include <vector> #include <cstdio> #include <algorithm> #include <set> #define EP 1e-10 using namespace std; typedef pair<long long, long long> ii; typedef pair<bool, int> bi; typedef vector<ii> vii; // Returns the orientation of three points in 2D space int orient2D(ii pt0, ii pt1, ii pt2) { long long result = (pt1.first - pt0.first)*(pt2.second

SDL doesn't compile in native enviroment

亡梦爱人 提交于 2019-12-12 01:52:05
问题 I'm trying to compile this piece of code with SDL #include <SDL.h> int main(int argc, char * argv[]){ return 0; } The file itself compiles fine with g++ -c main.cpp -ISDL/include But compiling with following command in cygwin using g++ g++ -o test main.o -lSDL2 -lSDL2main -L SDL/lib/x64 produces this huge error... it seems to me like a problem of SDL itself... $ g++ -o test main.o -lSDL2 -lSDL2main -L SDL/lib/x64 Warning: corrupt .drectve at end of def file SDL/lib/x64/SDL2main.lib(./x64

array size for extendible hashing

浪子不回头ぞ 提交于 2019-12-12 01:34:34
问题 If I want to use extendible hashing to store a maximum of 100 records, then what is the minimum array size that I need? I am guessing that an array of 100 would be sufficient, but I could be wrong. I also suspect that I can use a smaller array. 回答1: What do you know about your hash function? You mentioned extendible hashing. With extendible hashing you look at your hash as a bit string and typically implement the bucket lookup via a trie. Instead of a trie based lookup though I assume you are

Making and compiling C++ projects with multiple files

自闭症网瘾萝莉.ら 提交于 2019-12-12 01:28:16
问题 I am new to C/C++, I already know the basics and I am starting to learn more advanced concepts now. Currently I am developing a project using C++ and it is quite a big one, so structuring my project will be better. From what I have already seen, a good structure relies on, at least, to folders: /src and /include . All .cpp files should go in /src folder and .hpp ones in /include . Here the first doubt arose: how to include a header which is not in the same directory nor in a standard one?

OSX : File was built for archive which is not the architecture being linked (i386)

ぐ巨炮叔叔 提交于 2019-12-12 01:12:56
问题 I have the following makefile: PROG = tracecone RBASE= /Users/owner/Documents/raytrace GDIR=$(RBASE)/Graphics MDIR=$(RBASE)/VrMath ODIR=$(RBASE)/OpenglRender MANDIR=$(RBASE)/RaytraceMgr CFLAGS = -w -s -O2 -ansi -DSHM -m32 XLIBS = -lX11 -lXext -lXmu -lXext -lXmu -lXt -lXi -lSM -lICE LIBS = -lglut -lGLU -lGL RAYLIBS = -lraygraph -lvrmath INCLS = -I/usr/X11R6/include -I/usr/X11/include/GL INCL1 = -I$(GDIR) -I../RayTrace -I$(GDIR) -I$(MDIR) -I$(ODIR) -I$(MANDIR) LIBDIR = -L/usr/X11/lib -L/usr