User forums > Using Code::Blocks

Why class is not supported in GTK new project???

(1/1)

denisco:
I made first a simple project using the new gtk project...
At this point build fine and everything.
when I add my own code of C++ "something .cpp" the compiler treath C++ "class" as an error?

I made a C++ console app to see what would be different
beside the `pkg-config gtk+-2.0 --cflags` and -fexception

what do I have to do here?

frithjofh:
Hi,

could it be that Gtk is C and you are trying to use a C++ construct by using class?
And could you add some code please to understand the matter better?

Regards

nausea

denisco:
First of all I do have that project with GTK mix C and C++, build and worked fine.
Now I am trying to convert that project into codeblocks and it complains at

class CSize {
    int w, h;
};

/home/denisco/workspace/iWebBrowser/WinXDef.h|444|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘CSize’|

Hope that helps.

stahta01:
Just a few guesses at cause.

Guess 1:
  Code::Blocks assumes all files with extension .c is an C file.
  Change extension to cpp if doing C++ and does it change error?

Guess 2:
  In header, add an line of
  class CSize;
  before using CSize.

  This assumes CSize is not defined in header before errors.

Guess 3:
   That the name CSize is already used somewhere in an header; if so change name.

Tim S

MortenMacFly:

--- Quote from: stahta01 on January 11, 2009, 05:58:12 am ---Just a few guesses at cause.

--- End quote ---
Enough help.
denisco: Mind not posting questions not related to C::B? This violates our forum rules in case you don't know.
Topic locked.

Navigation

[0] Message Index

Go to full version