# Problem with juce namespace

**URL:** <https://forum.juce.com/t/problem-with-juce-namespace/1631>\
**Category:** General JUCE discussion\
**Created:** [April 18, 2007, 7:48am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631 "2007-04-18T07:48:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![X-Ryl669](https://avatars.discourse-cdn.com/v4/letter/x/a5b964/32.png) [@X-Ryl669](https://forum.juce.com/u/X-Ryl669)\
**Post date:** [April 18, 2007, 7:48am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/1 "2007-04-18T07:48:40Z")

</div>

Hi Jules,

I’ve a little problem while compiling with juce when both DONT\_SET\_USING\_JUCE\_NAMESPACE and JUCE\_NAMESPACE are set.

I’m using other namespaces where some symbols are redefined compared to Juce. For example, the tchar, uint8, uint32 and so on are not typedef the same way.

So, the compiler reject the object because of “ambiguous symbol” (uint8, tchar, etc…)

I think the typedefs Juce is using should be in Juce namespace too, and the jucer should allow to prefix all the type by “juce::” if an option is set to use juce in its own namespace.

So, for people who don’t care about juce namespace, they will be no change, but for other, it’s possible to use juce in its own private namespace (no global types, no global macro (T ?) which mess template definition) and so on.

For information the offending types are in :  
juce\src\juce\_core\text\juce\_CharacterFunctions.h  
juce\src\juce\_core\basics\juce\_MathsFunctions.h

Please notify if you are going to fix this or if I should modify in my local copy.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 18, 2007, 8:06am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/2 "2007-04-18T08:06:44Z")

</div>

Good point - yes, those should also be in the namespace, and it’s just an oversight that they’re not. I’ll certainly move them over for the next version.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 18, 2007, 8:10am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/3 "2007-04-18T08:10:02Z")

</div>

…no, hang on, they _are_ in the juce namespace… As you can see, there’s a namespace declared around the inclusion of juce\_MathsFunctions.h in juce\_StandardHeader.h

?

---

<div class="post-metadata">

**Author:** ![X-Ryl669](https://avatars.discourse-cdn.com/v4/letter/x/a5b964/32.png) [@X-Ryl669](https://forum.juce.com/u/X-Ryl669)\
**Post date:** [April 18, 2007, 8:38am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/4 "2007-04-18T08:38:41Z")

</div>

Right, my mistake. I’ve written code like :

```auto
#define JUCE_NAMESPACE
#define DONT_SET_USING_JUCE_NAMESPACE
#define JUCE_DONT_DEFINE_MACROS 1
#include "../../juce/juce.h"
```

where the first line was wrong (further down the road, it defined namespace { } which is the global namespace hence the conflict).

However, about the jucer, it should have an option to write juce:: in front of each juce specific name (or made it the default value, as it won’t hurt).  
Similarly, using JUCE\_T instead of T will be better

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 18, 2007, 9:08am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/5 "2007-04-18T09:08:12Z")

</div>

Yes, good point about the jucer, though it’d involve a lot of typing!

---

<div class="post-metadata">

**Author:** ![X-Ryl669](https://avatars.discourse-cdn.com/v4/letter/x/a5b964/32.png) [@X-Ryl669](https://forum.juce.com/u/X-Ryl669)\
**Post date:** [April 18, 2007, 9:43am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/6 "2007-04-18T09:43:08Z")

</div>

Well another point :

Please define the START\_JUCE\_APPLICATION macro to be using the juce namespace for Strings and so on…

---

<div class="post-metadata">

**Author:** ![X-Ryl669](https://avatars.discourse-cdn.com/v4/letter/x/a5b964/32.png) [@X-Ryl669](https://forum.juce.com/u/X-Ryl669)\
**Post date:** [April 18, 2007, 9:46am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/7 "2007-04-18T09:46:42Z")

</div>

I’ve made this change in juce.h:

```auto
#if defined (JUCE_GCC) || defined ( __MWERKS__ )

  #define START_JUCE_APPLICATION(AppClass) \
    int main (int argc, char* argv[]) \
    { \
        return JUCE_NAMESPACE::JUCEApplication::main (argc, argv, new AppClass()); \
    }

#elif JUCE_WIN32

  #ifdef _CONSOLE
    #define START_JUCE_APPLICATION(AppClass) \
        int main (int argc, char* argv[]) \
        { \
            return JUCE_NAMESPACE::JUCEApplication::main (argc, argv, new AppClass()); \
        }
  #elif ! defined (_AFXDLL)
    #ifdef _WINDOWS_
      #define START_JUCE_APPLICATION(AppClass) \
          int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR commandLine, int) \
          { \
              JUCE_NAMESPACE::String commandLineString (commandLine); \
              return JUCE_NAMESPACE::JUCEApplication::main (commandLineString, new AppClass()); \
          }
    #else
      #define START_JUCE_APPLICATION(AppClass) \
          int __stdcall WinMain (int, int, const char* commandLine, int) \
          { \
              JUCE_NAMESPACE::String commandLineString (commandLine); \
              return JUCE_NAMESPACE::JUCEApplication::main (commandLineString, new AppClass()); \
          }
    #endif
  #endif

#endif

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 18, 2007, 10:04am UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/8 "2007-04-18T10:04:00Z")

</div>

Right. Good idea, thanks!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 8:56pm UTC](https://forum.juce.com/t/problem-with-juce-namespace/1631/9 "2017-05-12T20:56:57Z")

</div>

Closed on May 12, 2017, 8:56pm UTC


