c++

Cross-platform svn management (Makefiles & Visual Studio)

I'm working on a little game called freegemas, it's an open source version of the classic Bejeweled written in C++ and using gosu as the graphic API. I've been developing it under Ubuntu Linux as usual, but the other day I wanted to give it a try and I compiled it on Windows using Visual Studio 2005 (which I had never used before). The p...

How to exclude certain #include directives from C++ stream?

I have this C++ file (let's call it main.cpp): #include <string> #include "main.y.c" void f(const std::string& s) { yy_switch_to_buffer(yy_scan_string(s.c_str())); yyparse(); } The file depends on main.y.c, which has to be generated beforehand by means of bison util. In other words, I can't compile main.c file if I forget to run b...

Complex initialization of const fields

Consider a class like this one: class MyReferenceClass { public: MyReferenceClass(); const double ImportantConstant1; const double ImportantConstant2; const double ImportantConstant3; private: void ComputeImportantConstants(double *out_const1, double *out_const2, double *out_const3); } There is a routine (ComputeIm...

Does usleep create thread cancellation point?

According to the Linux manpages, only the following functions are thread cancellation points: pthread_join, pthread_cond_wait, pthread_cond_timedwait, pthread_testcancel, sem_wait, sigwait. In my test program, thread exits on usleep. Thread function: void* ThreadFunction(void* arg) { int n = 0; pthread_setcancelstate(PTHREAD_C...

Watch content of stl vector via gdb

Hi there! I've got a stl vector of custom class objects defined in a global namespace (yeah, evil, I know). Now I would like to set a watchpoint in gdb to monitor possible changes in a (public) member variable for a certain element of this vector. Something like: watch custom_namespace::vec[123].aVariable If I do this, then gdb (Vers...

Can I use a preprocessor variable in #include directive?

This is what I'm trying to do: $ c++ -D GENERATED=build/generated-content main.cpp My main.cpp file: #include "GENERATED/header.h" void f() { /* something */ } Currently this code fails to compile. How should I fix it? And whether it's possible at all? ...

copy char* to char*

Here is part of my code: extern "C" REGISTRATION_API int extreme(char* lKey) { string s1; char *p=NULL; try { ifstream myfile ("extreme.txt"); int i=0; if (myfile.is_open()) { while (getline(myfile,s1)) { switch (i) { case 1: strcpy(p,s1.c_str()); lKey=p; bre...

GCC equivalent to VC's floating point model switch?

Does GCC have an equivalent compiler switch to VC's floating point model switch (/fp)? In particular, my application benefits from compiling with /fp:fast and precision is not a big deal, how should I compile it with GCC? ...

Variadic C++ function doesn't work when fetching arguments of type float

I have a variadic template function: template<typename T, typename ArgType> vector<T> createVector(const int count, ...) { vector<T> values; va_list vl; va_start(vl, count); for (int i=0; i < count; ++i) { T value = static_cast<T>(va_arg(vl, ArgType)); values.push_back(value); } va_end(vl); return values; } Thi...

Problem With Python Bindings on a Widget That uses GStreamer

First, some background information: I'm currently developing a program for the Nokia N900 using Python and PyQt4. The program accesses the phone's camera. I have figured out how to use GStreamer in a Qt widget to capture the video. It turns out that I need access to a somewhat obscure gstreamer interface which I don't believe I can ac...

assign elements in vector declared with new. C++

I am trying to use a large 2D vector which I want to allocate with new (because it is large). if I say: vector< vector<int> > bob; bob = vector< vector<int> >(16, vector<int>(1<<12,0)); bob[5][5] = 777; it works. But if I say: std::vector< std::vector<int> > *mary; mary = new vector< vector<int> >(16, vector<int>(1<<12, 0)); mary[5]...

Add static library to CLR Windows Forms Project, Get "unresolved external symbol _MAIN__"

I've reduced this issue to, with Visual Studio 2005, in Release mode: Create a new Windows Forms app Change to /CLR Check that the default Form1 runs Add one static library (which itself is linked with BLAS.lib, clapack.lib, libf2c.lib) Then I compile and link and get error LNK2019: unresolved external symbol MAIN_ referenced in...

C++ void type - how?

typedef void(Object Sender) TNotifyEvent; This is what I'm trying to do from Delphi to C++, but it fails to compile with 'type int unexpected'. The result should be something I can use like that: void abcd(Object Sender){ //some code } void main{ TNotifyEvent ne = abcd; } How do I make such type(of type void)? I'm not very fa...

How to use Eigen, the C++ template library for linear algebra?

Hi Guys, I have an image processing algorithm which makes of matrices, I have my own matrix operation codes (Multiplication, Inverse...) with me. But the processor I use is ARM Cortex-A8 processor, which has NEON co-processor for vectorization, as matrix operations are ideal cases for SIMD operations, I asked the compiler (-mfpu=neon -m...

Is it possible to declare void pointer to a template function in C++?

Is it possible? If as I have understood is correct, void pointer can point to any type. Therefore, a template function (undeclared type) is possible? or void pointer is only reserve for "variable" not function? Then what about void function pointer? ...

JNI method returns old data

Hello all. I've spent whole day on this problem and still have no idea how to solve it. Here is the simplified code JAVA class javaclass{ private volatile boolean isTerminated; public void javamethod() { log.logInfo("java :"+isTerminated()); } public int isTerminated() { return (isTerminated) ? 1 : 0; } public ...

Class method with number of arguments specified by integer template parameter

Was not exactly sure how to phrase this question or what to search on so if this is the same as another question please close and redirect to the appropriate question. Suppose template<typename Type, int Size> class vector { Type data[Size]; } Is it possible to replace a constructor which takes Size number of arguments in template ...

What are these called

Possible Duplicate: What does ? do in C++? What are these kind of statements in c++ called: testNumber > 1 ? true : false; ...

How do I get STL std::string to work with unicode on windows?

Hello All, At my company we have a cross platform(Linux & Windows) library that contains our own extension of the STL std::string, this class provides all sort of functionality on top of the string; split, format, to/from base64, etc. Recently we were given the requirement of making this string unicode "friendly" basically it needs to s...

Is it possible to create stack class that take any type of variable? not only 1 type...

I have seen stack class that uses the template to define the type of data the stack hold. What if I want a stack that hold different type of data? I have a little thought into it and come close to using void pointer (but void pointer can't be dereferenced, so it is not the correct solution) So... Is it possible to have such a class? ...