devxlogo

The Linkage Type of Typedef Names

The Linkage Type of Typedef Names

By default, a typedef name declared in the global scope has internal linkage. This means that separately compiled source files can’t refer to a typedef declared in another source file, unless that typedef is explicitly declared “extern.” In this respect, C++ is different from C, which make typedef names global by default. Thus, in C++ you are allowed to define the same typedef name in every separately compiled source file as long as the definitions are identical:

 // file first.cpp  typedef int I; // visible only in the scope of this file  void func(I);// file second.cpp  typedef int I; // visible only in the scope of this file  float func2(I);
See also  How College Students Can Shape the Future of Tech Responsibility
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist