# What is the proper way to structure C++ macros with modularity in mind?

**URL:** <https://root-forum.cern.ch/t/what-is-the-proper-way-to-structure-c-macros-with-modularity-in-mind/64598>\
**Category:** Newbie\
**Tags:** cling, root\
**Created:** [January 19, 2026, 9:39pm UTC](https://root-forum.cern.ch/t/what-is-the-proper-way-to-structure-c-macros-with-modularity-in-mind/64598 "2026-01-19T21:39:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![deltaSpawn0040](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@deltaSpawn0040](https://root-forum.cern.ch/u/deltaSpawn0040)\
**Post date:** [January 19, 2026, 9:39pm UTC](https://root-forum.cern.ch/t/what-is-the-proper-way-to-structure-c-macros-with-modularity-in-mind/64598/1 "2026-01-19T21:39:22Z")

</div>

* * *

_ROOT Version:_ 6.34.08 (Yes, I know this is not the latest version)  
_Platform:_ NixOS Linux, x86\_64  
_Compiler:_ Cling (if that is the default when nothing has been done to change it)

This installation of ROOT is from Nixpkgs, though I don’t think that’s relevant.

UNNECESSARY BACKGROUND INFORMATION:  
Please be forewarned, this question is going to seem very stupid. I’m using this program for a very simplistic purpose compared to what it’s normally used for, to do homework for an introductory statistics course, specifically to gain experience working with C++ and CLI applications. I am neither a professional nor a student in experimental physics, I’m a computer science nerd who saw that there was a masterfully efficient calculator that was entirely text based and had to be programmed with C++ and just had to learn how to use it.

THE ACTUAL QUESTION:

I would like some advice on how to structure my C++ macros so that I can use them to modularly define series of operations on one dimensional vectors of type double. Originally, I just put each function into its own .C file, splitting them up as best I could so that any code I thought I’d need to use twice would be its own .C file with one singular function within it. All of these .C files would be in this one folder I called “ws” for “workspace”, and that’s where I would use them and build new functionality out of these base atomic functions.

However, the problem: I can’t #include a file that’s already included in another file that is also included, so if I want to use two files that both use the same file, I’m out of luck. That’s when I realized I was probably structuring my code VERY wrong or there’s some trick I need that I don’t know about. I would like to know how a modular structure is supposed to be achieved in this unique environment.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [January 20, 2026, 3:27am UTC](https://root-forum.cern.ch/t/what-is-the-proper-way-to-structure-c-macros-with-modularity-in-mind/64598/2 "2026-01-20T03:27:17Z")

</div>

> **[2.12 — Header guards – Learn C++](https://www.learncpp.com/cpp-tutorial/header-guards/)**
