20

I have the following header files:

https://gist.github.com/wemakeweb/5501443 and the compiler always reports "Unknown Type name Class". I have included Forward Declaration, to break circular including , where i think i have to. What did i forget?

Edit: i put it all in one header file, and the compiler still reports "expected ; after top level declarator"

https://gist.github.com/wemakeweb/5583500

Edit 2 Now im getting linker errors. "Undefined symbols for architecture x86_64"

Solved, Problems were

  1. Circular Including
  2. main.c instead of main.cpp
  3. the actual code was in a static lib which was not linked properly
Sebastian Otto
  • 15,139
  • 4
  • 18
  • 21

2 Answers2

42

This error? error: unknown type name ‘class’

You're probably compiling it as C rather than C++.

Make sure your source file has a .cpp extension, and than any relevant compiler flags are set correctly. (It helps if you include the exact error message and line numbers. Don't try and retype, just cut+paste.)

Roddy
  • 66,617
  • 42
  • 165
  • 277
  • 1
    the first error i get in the Header file is "expected ; after top level declarator" – Sebastian Otto May 15 '13 at 12:25
  • 2
    @SepOSep Yes, but what line number and file? There's nothing wrong with the header file, so also show the cpp source that's trying to include it. You do *have* a .cpp file, don't you? – Roddy May 15 '13 at 12:34
  • 1
    Yes it was an main.c file and i now changed it to main.cpp . Im now fighting against a Linker error "Undefined symbols for architecture x86_64". – Sebastian Otto May 15 '13 at 13:23
  • 1
    @SepOSep : http://stackoverflow.com/questions/12110184/c-undefined-symbols-for-architecture-x86-64-when-compiling-on-mac-osx-lion – Roddy May 15 '13 at 13:32
7

You have at least one cyclic include dependency between Feld.h and Figur.h. The forward declarations have no effect if you also include the headers. Just remove the includes.

juanchopanza
  • 223,364
  • 34
  • 402
  • 480