Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Wierdest error I have ever seen

This thread is locked; no one can reply to it. rss feed Print
Wierdest error I have ever seen
kazzmir
Member #1,786
December 2001
avatar

As you can tell by the incredibly informative title, i have a strange error. Here is the exact code I am using.

TMenu::TMenu( BITMAP * _background, int x, int y, int major_val ):
middle_x( x ),
middle_y( y ),
major( major_val ){ // error on this line
  background = _background;
  previous = NULL;

  mouse.x = x;
  mouse.y = y;
  mouse.grab( background );
  selected = NULL;
}

On the line i have commented, i get this error from gcc:

TMenu.cpp:13:anachronistic old style base class initializer
TMenu.cpp:13: unnamed initializer for 'TMenu', which has no base classes

The above code worked before i added major( major_val ) so i have no idea what an anachronistic old style whatever is.

23yrold3yrold
Member #1,134
March 2001
avatar

What type is major?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

kazzmir
Member #1,786
December 2001
avatar

cmon, im not stupid. major is an int.

23yrold3yrold
Member #1,134
March 2001
avatar

Is major inherited (and I assume middle_x and middle_y are not)?

If so, initialize that variable in the constructor body instead ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

kazzmir
Member #1,786
December 2001
avatar

TMenu is a base class that no class is derived from. All variables are contained in TMenu. Major is declared in the next line down from middle_x, middle_y, more specifically it is declared protected.

Yes, declaring it in the constructor body works but i was just wondering why the way im doing it gives an error.

gillius
Member #119
April 2000

Is major defined as a macro somewhere. I had that problem in a class once that some macro from a UNIX header happened to be the same name, and it generated weird warnings.

Try playing with the spaces, seeing if it's a bug in GCC. Make sure the initializer list is in order of declaration (but that would give you a warning, and not an error).

Gillius
Gillius's Programming -- https://gillius.org/

kazzmir
Member #1,786
December 2001
avatar

Yea, apparently this code reveals a warning:

#ifdef major
#warning WTF??
#endif

Upon further investigation, major is defined by <vector>. I searched through the STL header files, but found no mention of major.

[edit] found it, or found a major being defined somewhere in the system. In /usr/include/linux/kdev_t.h on line 81 it defines major as

#define major(d) MAJOR(d)

Go to: