user1499: I have a project in which basically i have to concatenate existing code.
Each code comes with its own #defines.
But defines are not touched by the compiler, but the preprocessor.
Each snippet of the program will exist in its own fucntion.
Is it possible to include the #defines of each program - now each function, inside this function (and visible only to this function's scope)?
The proper way to do it, would be to replace text reassignment from #define to typedef?
I understand typedef is originally for defining types. But can it be used here? Is there another alternative?

user4143: #define value 255

Can be replaced with
const int value = 255;


user30198: It is possible to use "namespace { ... }" to create local defines for a *.cpp file.
In the Arduino IDE all *.ino files are combined in a single *.cpp file, therefor the "namespace" is not very useful.
When you create new tabs in the Arduino IDE and name them *.cpp, then you have different *.cpp files. Then you can use the "namespace" to create defines that are only valid for that *.cpp file.
More info: Hackaday: Using Modern C++ Techniques with Arduino

1499: <p>I have a project in which basically i have to concatenate existing code.
Each code comes with its own #defines.
But defines are not touched by the compiler, but the preprocessor.</p>

<p>Each snippet of the program will exist in its own fucntion.</p>

<p>Is it possible to include the #defines of each program - now each function, inside this function (and visible only to this function's scope)?</p>

<p>The proper way to do it, would be to replace text reassignment from #define to typedef?</p>

<p>I understand typedef is originally for defining types. But can it be used here? Is there another alternative?</p>
 4143: <pre><code>#define value 255
</code></pre>

<p>Can be replaced with</p>

<pre><code>const int value = 255;
</code></pre>
 30198: <p>It is possible to use "namespace { ... }" to create local defines for a *.cpp file.<br>
In the Arduino IDE all *.ino files are combined in a single *.cpp file, therefor the "namespace" is not very useful.</p>

<p>When you create new tabs in the Arduino IDE and name them *.cpp, then you have different *.cpp files. Then you can use the "namespace" to create defines that are only valid for that *.cpp file.</p>

<p>More info: <a href="http://hackaday.com/2017/05/05/using-modern-c-techniques-with-arduino/" rel="nofollow noreferrer">Hackaday: Using Modern C++ Techniques with Arduino</a></p>
