简体   繁体   中英

Difference between inline void and void inline in C/C++

我只需要知道 C/C++ 编译器中的inline voidvoid inline之间有什么区别。

There's no semantic difference. In C's grammar, inline is a "function-specifier".

If you look at the definition of a declaration :

      declaration:
             declaration-specifiers init-declarator-listopt ;
             static_assert-declaration
      declaration-specifiers:
             storage-class-specifier declaration-specifiersopt
             type-specifier declaration-specifiersopt
             type-qualifier declaration-specifiersopt
             function-specifier declaration-specifiersopt
             alignment-specifier declaration-specifiersopt
      init-declarator-list:
              init-declarator
              init-declarator-list , init-declarator
      init-declarator:
              declarator
              declarator = initializer

you'll see that function-specifiers in a declaration (which for functions, is part of definitions too) can be arbitrarily permuted with storage-class specifiers (eg, static ), type-specifiers (eg, int , long , signed , unsigned ), type qualifiers ( const , volatile , restrict ) and alignment specifiers ( _Alignas(type_name) or _Alignas(constant_expression) ).

There are no differences, but is suggested to use inline void .

Note that inline functions are supported in C++ and C99 though with different semantics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM