In reply to Sanjeeva Dinesh:
sorry, I didn’t get it. Can you please elaborate it.
In file c_file.sv:
#ifndef __C_FILE_SV__
#define __C_FILE_SV__
class C;
function new();
endfunction : new
endclass : C
#endif
We include c_file.sv in a_file.sv for using:
#ifndef __A_FILE_SV__
#define __A_FILE_SV__
#include "c_file.sv"
class A;
C _c;
function new();
endfunction : new
endclass : A
#endif
We also include it in b_file.sv:
#ifndef __B_FILE_SV__
#define __B_FILE_SV__
#include "c_file.sv"
class B;
C _c;
function new();
endfunction : new
endclass : B
#endif
Now, both a_file.sv and b_file.sv include c_file.sv, if we dont specify #ifndef/define in c_file.sv, then class C will be compiled twice and we will get error “multiple declaration” of class C. If we have these macros, c_file.sv only be compiled once, the second time will be ignore because C_FILE_SV is defined.