开发者

methods declared, but never defined in Geant4 source code

During my searches through the Geant4 source code, I have noticed several times that there are methods which are declared in the header but are never defined with any associated code (pardon any falsities in my lingo (I'm an engineer)).

An example would be a method defined like:

G4TrackVector* GetfSecondary();

which has no im开发者_JAVA技巧plementation in the header or the source file, is not virtual, and yet it is used on various occasions by the program and the program runs from this compiled code. At first I thought it was just some cool code hiding trick with doxygen, but I now see it is not! This is a common occurrence in the code.

Could someone explain what's going on?

Thanks


The GetSecondary() function is a member of the G4Step class (defined in G4Step.hh) and is implemented inline in G4Step.icc. G4Step.icc is included at the end of G4Step.hh.

I'm guessing you were looking in the source directory instead of the include directory for the implementation, but the include dir is the propper place for inline implementation.

In the future if you are on *nix, you can try a grep -r <FunctionName> . from the top of the project directory to find all mentions of a function, which should include the implementation.


The code would fail to compile if this were the case. You just aren't looking in the right place for it's definition. Or just not noticing it. Calling a declared function with no definition is an error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜