Upozornění kompilátoru (úroveň 2) C5046
'function' : Symbol zahrnující typ s interní vazbou není definován
Poznámky
Kompilátor zjistil použití funkce, která nemá definici, ale podpis této funkce zahrnuje typy, které nejsou viditelné mimo tuto jednotku překladu. Vzhledem k tomu, že tyto typy nejsou externě viditelné, nemůže žádná jiná jednotka překladu poskytnout definici této funkce, takže program nelze úspěšně propojit.
Mezi typy, které nejsou viditelné napříč jednotkami překladu, patří:
Typy deklarované uvnitř anonymního oboru názvů
Místní nebo nepojmenované třídy
Specializace šablon, které tyto typy používají jako argumenty šablony.
Toto upozornění je nové v sadě Visual Studio 2017 verze 15.8.
Příklad
Tato ukázka ukazuje dvě upozornění C5046:
// C5046p.cpp
// compile with: cl /c /W2 C5046p.cpp
namespace {
struct S {
// S::f is inside an anonymous namespace and cannot be defined outside
// of this file. If used, it must be defined somewhere in this file.
int f();
};
}
// g has a pointer to an unnamed struct as a parameter type. This type is
// distinct from any similar type declared in other files, so this function
// cannot be defined in any other file.
// Note that if the struct was declared "typedef struct { int x; int y; } S, *PS;"
// it would have a "typedef name for linkage purposes" and g could be defined
// in another file that provides a compatible definition for S.
typedef struct { int x; int y; } *PS;
int g(PS p);
int main()
{
S s;
s.f(); // C5046 f is undefined and can't be defined in another file.
g(nullptr); // C5046 g is undefined and can't be defined in another file.
}
Pokud chcete tyto problémy vyřešit, definujte funkce v tomto souboru.