views:

1331

answers:

1

I have a header file with some inline template methods. I added a class declaration to it (just a couple of static methods...it's more of a namespace than a class), and I started getting this compilation error, in a file that uses that new class.

There are several other files that include the same .h file that still compile without complaint.

Googling for the error gives me a bunch of links to mailing lists about bugs on projects that have a similar error message (the only difference seeming to be what the constructor, destructor, or type conversion is supposed to precede).

I'm about ready to start stripping everything else away until I have a bare-bones minimal sample so I can ask the question intelligently, but I figured I'd take a stab at asking it the stupid way first:

Can anyone give me a basic clue about what this error message actually means so I might be able to begin to track it down/google it?

Just for the sake of completeness, the first example of where I'm seeing this looks more or less like

namespace Utilities
{
   template <typename T> GLfloat inline NormalizeHorizontally(T x)
   {
      GLfloat scaledUp = x*2.0;
      GLfloat result = scaledUp / Global::Geometry::ExpectedResolutionX;
      return result;
   }
}
+7  A: 

It means that you put the "inline" keyword in the wrong place. It needs to go before the method's return type, e.g.

 template <typename T> inline GLfloat  NormalizeHorizontally(T x)

Simple as that.

The reason that you got this message on one compilation unit and not others may be because it is a templated function that was not being instantiated from those other compilation units.

Generally, if you get an "expected blah blah before foobar" error, this is a parsing error and it often indicates a simple syntax mistake such as a missing semicolon, missing brace, or misordered keywords. The problem is usually somewhere around the portion mentioned, but could actually be a while back, so sometimes you have to hunt for it.

Tyler McHenry
Beat me by a minute... (deleting my answer now)
Zifre