Skip to content

Commit

Permalink
Update intro.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
jiperl committed Sep 30, 2021
1 parent d18b5a5 commit f8e9d0c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extension-docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,23 @@ You can see there what the special comment string is for each type of class (Geo
While it is beyond the scope of this User Guide to teach C++ programming, one issue that has come up a few times might be worth mentioning.
Any time you see an example use a variable with a name starting with f, such as fEnvelopeLog or fEnevelopePhys,
you should be careful not to redeclare your own local version of this variable.
So go ahead and set them as::
So go ahead and set them as

.. code-block:: c++

fEnvelopeLog = CreateLogicalVolume(something);
fEnvelopePhys = CreatePhysicalVolume(fEnvelopeLog);

Do <b>not</b> set them as::
Do **not** set them as

.. code-block:: c++

G4LogicalVolume* fEnvelopeLog = CreateLogicalVolume(something);
G4VPhysicalVolume* fEnvelopePhys = CreatePhysicalVolume(fEnvelopeLog);

The latter case would create a new, local copy of the variable, and would mean that when the base classes go to do other work with
these objects, they would find them to be unset, giving various crashes (probably segmentation faults).
You can read more elsewhere about this general topic, <a href="https://en.wikipedia.org/wiki/Variable_shadowing">Variable Shadowing</a>.
You can read more elsewhere about this general topic, Variable Shadowing <https://en.wikipedia.org/wiki/Variable_shadowing>.

To build your new TOPAS executable that incorporates all of your extensions, you run CMake with an argument that tells it the location of your extensions. Your extensions then coexist with the rest of the TOPAS code.

Expand Down

0 comments on commit f8e9d0c

Please sign in to comment.