Archive for c++

compile cuda program in device emulation mode

Prior to 3.0 you can just compile with the -deviceemu flag:

nvcc -deviceemu main.cu

In 3.0, this was changed such that you should link against cudartemu instead of cudart
In 3.1, emulation was removed.

So if want device emulation, you need to use version 3.0 or earlier.

A

Leave a Comment

here is inaccessible

You probably forgot to make something public in your class:

class A {
  A() {};
};
class A {
public:
  A() {};
};

g++ ‘s version of the error message is a bit more clear:

error: A::A() is private

Leave a Comment

A tricky situation..

There is an awesome syntax error in the the following snippit. Either line 4 or line 5 has the error, see if you can spot it.

int main() {
  int value = 0;
  int othervalue = 1;
  (50 + value – 1) / othervalue;
  (50 + value - 1) / othervalue;
}

Here’s the error message from g++.

a.cpp:4: error: stray ‘\342’ in program
a.cpp:4: error: stray ‘\200’ in program
a.cpp:4: error: stray ‘\223’ in program

MSVS’s error message was something along the lines of:

expected `)' before numeric constant

So what’s the answer? The – on line 4 isn’t a -.

A

Leave a Comment