Is there a way to detect inline function ODR violations?

前端 未结 2 1856
一个人的身影
一个人的身影 2021-01-04 01:54

So I have this code in 2 separate translation units:

// a.cpp
#include 
inline int func() { return 5; }
int proxy();
int main() { printf(\"%d\         


        
2条回答
  •  悲哀的现实
    2021-01-04 02:18

    The simplest way to detect such concerns is to copy all the functions into a single compilation unit (create one temporarily if needed). Any C++ compiler will then be able to detect and report duplicate definitions when compiling that file.

提交回复
热议问题