Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why do I get “duplicate definition” error messages when I compile the foo.i file that is generated from the -P preprocessing option?

0
Posted

Why do I get “duplicate definition” error messages when I compile the foo.i file that is generated from the -P preprocessing option?

0

By default, the compiler allows template definitions to be separate from their declarations. Refer to the C++ User’s Guide sections 5.2.1 and 5.2.2 for further discussion of the template definitions model or refer to the index of the C++ User’s Guide for pointers to descriptions of the definitions separate and definitions included models. When the compiler sees a declaration without a definition of a needed template in a .h or .i file, it looks for a template definition file. A file with the same name as the .h or .i file but with one of the extensions c, cc, C, c++, or cpp, is assumed to have template definitions. If such a file exists, it is included automatically, as documented in the C++ manual. Suppose file foo.cc is compiled with -P, thus generating foo.i, and has a declaration for a needed template but no definition. The compiler looks for a definition file and finds foo.cc. The foo.cc file gets included automatically, which results in duplicate definitions. You can turn off the

0
10

By default, the compiler allows template definitions to be separate from their declarations. Refer to the C++ User’s Guide sections 5.2.1 and 5.2.2 for further discussion of the template definitions model or refer to the index of the C++ User’s Guide for pointers to descriptions of the definitions separate and definitions included models. When the compiler sees a declaration without a definition of a needed template in a .h or .i file, it looks for a template definition file. A file with the same name as the .h or .i file but with one of the extensions c, cc, C, c++, or cpp, is assumed to have template definitions. If such a file exists, it is included automatically, as documented in the C++ manual. Suppose file foo.cc is compiled with -P, thus generating foo.i, and has a declaration for a needed template but no definition. The compiler looks for a definition file and finds foo.cc. The foo.cc file gets included automatically, which results in duplicate definitions. You can turn off the

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123