# uint32 not playing nice with namespaces

**URL:** <https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947>\
**Category:** Audio Plugins\
**Created:** [May 21, 2009, 9:50pm UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947 "2009-05-21T21:50:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy-cytomic](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/andy-cytomic/32/1838_2.png) [@andy-cytomic](https://forum.juce.com/u/andy-cytomic)\
**Post date:** [May 21, 2009, 9:50pm UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/1 "2009-05-21T21:50:27Z")

</div>

This is very odd.

```auto
#include "juce.h"

using namespace juce;
uint32 a; // this does not work

juce::uint32 b; // this is fine
```

I have no idea why this would be the case. Does anyone else have any ideas on this?

---

<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 22, 2009, 9:32am UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/2 "2009-05-22T09:32:51Z")

</div>

In juce.h it already does a “using namespace juce”, so maybe if you give the namespace directive again, it could be compounding them into “juce::juce::uint32”?

---

<div class="post-metadata">

**Author:** ![andy-cytomic](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/andy-cytomic/32/1838_2.png) [@andy-cytomic](https://forum.juce.com/u/andy-cytomic)\
**Post date:** [May 22, 2009, 11:24am UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/3 "2009-05-22T11:24:39Z")

</div>

Nope. Without the first using namespace juce you get the same error. Here is the full list of what I have tried with gcc4 on mac:

```auto
#include "juce.h"

namespace juce
{
    uint32 a; // good
}

juce::uint32 b; // good

uint32 c; // error: 'uint32' does not name a type

using namespace juce::uint32; // error: expected namespace-name before ';' token, error: '<type error>' is not a namespace

using namespace juce;
uint32 d; // error: 'uint32' does not name a type

```

So all the forms of using namespace where I don’t have to explicitly have juce:: in front of uint32 uint8 etc don’t work

Andrew Simper

---

<div class="post-metadata">

**Author:** ![vishvesh](https://avatars.discourse-cdn.com/v4/letter/v/85e7bf/32.png) [@vishvesh](https://forum.juce.com/u/vishvesh)\
**Post date:** [May 22, 2009, 2:01pm UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/4 "2009-05-22T14:01:52Z")

</div>

Have you added this before including juce.h

```auto
#define DONT_SET_USING_JUCE_NAMESPACE
#define DONT_AUTOLINK_TO_JUCE_LIBRARY
```

---

<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 22, 2009, 2:08pm UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/5 "2009-05-22T14:08:09Z")

</div>

The one thing you didn’t mention was:

```auto
using juce::uint32;
```

…though I have to admit I’ve no idea why there’d be a problem. Are you mixing in any other headers?

---

<div class="post-metadata">

**Author:** ![andy-cytomic](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/andy-cytomic/32/1838_2.png) [@andy-cytomic](https://forum.juce.com/u/andy-cytomic)\
**Post date:** [May 22, 2009, 2:26pm UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/6 "2009-05-22T14:26:47Z")

</div>

[quote=“vishvesh”]Have you added this before including juce.h

`
#define DONT_SET_USING_JUCE_NAMESPACE
#define DONT_AUTOLINK_TO_JUCE_LIBRARY
`[/quote]  
Great, thanks for pointing those out!

Andrew Simper

---

<div class="post-metadata">

**Author:** ![andy-cytomic](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/andy-cytomic/32/1838_2.png) [@andy-cytomic](https://forum.juce.com/u/andy-cytomic)\
**Post date:** [May 22, 2009, 2:30pm UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/7 "2009-05-22T14:30:34Z")

</div>

[quote=“jules”]The one thing you didn’t mention was:

```auto

```

…though I have to admit I’ve no idea why there’d be a problem. Are you mixing in any other headers?[/quote]

There are no other headers that I pull in, it’s something included from “juce.h” that is doing it. Thanks for pointing out the correct usage of “using” this works great 🙂 So there must be something that juce is including that defines uint32 uint8 etc and then the automatic “using namespace juce” causes this to clash and the compiler not allow you to use uint32 without first telling it which one you mean explicitly.

So thanks for the help, the problem is solved by:

`#include "juce.h"
using juce::uint32;
using juce::uint8;
`

Andrew Simper

---

<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 24, 2009, 10:09am UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/8 "2009-05-24T10:09:40Z")

</div>

That’s odd - I often use uint32 in my apps and don’t remember doing anything like this to make it work. You’ve not got a prefix header defined for your project, have you?

---

<div class="post-metadata">

**Author:** ![andy-cytomic](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/andy-cytomic/32/1838_2.png) [@andy-cytomic](https://forum.juce.com/u/andy-cytomic)\
**Post date:** [May 24, 2009, 11:22am UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/9 "2009-05-24T11:22:21Z")

</div>

> [@jules](#):
>
> That’s odd - I often use uint32 in my apps and don’t remember doing anything like this to make it work. You’ve not got a prefix header defined for your project, have you?

I am not using a prefix header. Are you possibly inside the “juce” namespace with your projects? If so then you will not have any issues.

Andrew Simper

---

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [May 25, 2009, 9:24am UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/10 "2009-05-25T09:24:03Z")

</div>

I’ve encountered the same issue some time ago and posted about it. check it out for more informations about the cause: [http://www.rawmaterialsoftware.com/juceforum/viewtopic.php?p=21209#21209](http://www.rawmaterialsoftware.com/juceforum/viewtopic.php?p=21209#21209)

---

<div class="post-metadata">

**Author:** ![rbocquier](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@rbocquier](https://forum.juce.com/u/rbocquier)\
**Post date:** [May 25, 2009, 6:16pm UTC](https://forum.juce.com/t/uint32-not-playing-nice-with-namespaces/3947/11 "2009-05-25T18:16:50Z")

</div>

I’ve recently encountered this issue and found out that if the Base SDK in the project settings was “Current Mac OS”, the namespace was needed, and if, on the other hand, it was “Mac OSX 10.4”, then the namespace wasn’t needed.

Hope this helps…
