Search code examples
c++visual-studio-2012typedeflanguage-lawyergcc4

typedef - Primitive type to primitive type


Is it valid C++ to have a typedef for a primitive type to another primitive type ?

typedef int long;

On VS 2012, warning is issued but compiles fine.

warning C4091: 'typedef ' : ignored on left of 'long' when no variable is declared

But on gcc-4.3.4, it fails.

error: declaration doesnot declare anything.

Which compiler is standard conformant ?

PS: I won't write something like this in production code. Just came up with the thought and checking.


Solution

  • Is it valid C++

    No. C++11, § 7.1.3.6:

    In a given scope, a typedef specifier shall not be used to redefine the name of any type declared in that scope to refer to a different type.