Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#ifndef DER_INCLUDEGUARD #define DER_INCLUDEGUARD #include <iostream> inline void foo () { std::cout << "foo\n"; } void bar () { std::cout << "bar\n"; } #endif |
Anonymous
unregistriert
Zitat
In pre-standard C++, inline affected the linkage type of a function. This is not the case anymore. In standard C++, inline has no effect on the linkage of a function.
Zitat von »"Der C++Standard"«
3.2 One definition rule
§3
Every program shall contain exactly one definition of every non-inline function or object that is used in that program; no diagnostic required. The definition can appear explicitly in the program, it can be found in the standard or a user-defined library, or (when appropriate) it is implicitly defined. An inline function shall be defined in every translation unit in which it is used.
§5
There can be more than one definition of a class type, enumeration type, inline function with external linkage[b], class template, non-static function template, static data member of a class template, member function template, or template specialization for which some template parameters are not specified in a program provided that each definition appears in a different translation unit, and provided the definitions satisfy the following requirements.
[...]
Zitat von »"Der C++ Standard"«
7.1.1 Storage class specifiers
§7
[...]
inline void h(); // external linkage
[...]
Zitat von »"helium"«
Zitat von »"Der C++Standard"«
§7
[...]
inline void h(); // external linkage
[...]
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
//irgendeinheader.h #pragma once void inline f1(); //-------------- //irgendeincpp.cpp void inline f1(){ } //------------- //einanderesfile.cpp #include "irgendeinheader.h" int main(){ f1(); return 0; } |
Werbeanzeige