Reputation: 33
There is a lot of information out there on the use of inline
and how to properly do so for the desired intent such as here (which I am currently using as a reference) Inline Functions in C.
When I attempt to implement what is speficied in the page I get compiler errors for
using INLINE = extern inline;
and even just
using INLINE = extern;
The compiler says "expected type specifier before extern"
What I'm wondering is why can I use using
this way?
Is it because using
is really just reserved for types and substitutions?
Thank you so much! I totally missed the fact that I was reading through C reference. This is good news as it didn't seem like there was a really good way to deal with things from what I was reading but it is probably that way as it is out of date compared to what they are doing in C++11 now.
Upvotes: 1
Views: 95
Reputation: 170064
Is it because using is really just reserved for types and substitutions?
I don't know what you mean by substitutions, but yes to the reservation for types. An alias declaration is for declaring new names for types. A pair of specifiers doesn't form a type. You can't even make it work by superficially adding a type name there, since the extern
and inline
specifiers only apply to object and function identifiers, and not their associated type.
The article uses a macro (#define
) because token substitution is the only way to create user defined specifiers like you want to do.
It's also worth noting that in C++ inline
and extern inline
are the same thing. It's only in C (a different language to C++, and the subject of the linked article) that inline
doesn't imply linkage, requiring you to specify extern
.
Upvotes: 4