devxlogo

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);

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Seasoned Architects Evaluate New Tech

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.