# Disable optimizations per file or classes

**URL:** <https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343>\
**Category:** General JUCE discussion\
**Created:** [July 6, 2016, 6:43pm UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343 "2016-07-06T18:43:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [July 6, 2016, 6:43pm UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343/1 "2016-07-06T18:43:20Z")

</div>

Projucer doen’t supports to set optimizations per file.  
My anticrack/licenser has many cpp/h files, and for security reasons, I do not want these files to be compiled with optimizations.  
Before juce, I set this option from the IDE (vs/xcode) but now, every time  
when I save the project with projucer I lost these options.

Ok, on visual studio “#pragma optimize( “”, off )” I think it will work. But with clang is not clear how to do that (Apple LLVM version 7.3.0 (clang-703.0.29)).

Any advice?

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [July 6, 2016, 7:39pm UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343/2 "2016-07-06T19:39:08Z")

</div>

As a longshot/workaround would it work compile this part of the code as a static lib, then include/link to that?

---

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [July 6, 2016, 8:13pm UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343/3 "2016-07-06T20:13:14Z")

</div>

mmmh, I would not risk, anyway I think that would be a mess in my case, for each product, a script generates the cpps files for the licenser.  
pragma optimize does not works on clang? some talk about it works and others that it doent work.

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [July 7, 2016, 7:49am UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343/4 "2016-07-07T07:49:42Z")

</div>

I agree with martin, I think a static lib is the only way to go here.

---

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [July 7, 2016, 6:46pm UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343/5 "2016-07-07T18:46:35Z")

</div>

I was thinking about this, and looking for alternatives, I have not found anything.

Thanks guys, I’ll do as static lib.

---

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [July 7, 2016, 7:28pm UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343/6 "2016-07-07T19:28:15Z")

</div>

An other question, in the final compiled product, the static lib exported symbols can be striped?

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [July 8, 2016, 8:06am UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343/7 "2016-07-08T08:06:57Z")

</div>

Yes. A static lib is just an archive of .o files. So linking to a static lib or having the .cpp file in your project is really no different. If you strip your symbols at the very end of your build you will be fine.

---

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [July 8, 2016, 5:59pm UTC](https://forum.juce.com/t/disable-optimizations-per-file-or-classes/18343/8 "2016-07-08T17:59:32Z")

</div>

Great! thanks!
