# \[BUG\] juce::ssize\_t not being defined on POSIX

**URL:** <https://forum.juce.com/t/bug-juce-ssize-t-not-being-defined-on-posix/59695>\
**Category:** General JUCE discussion\
**Created:** [January 26, 2024, 8:06am UTC](https://forum.juce.com/t/bug-juce-ssize-t-not-being-defined-on-posix/59695 "2024-01-26T08:06:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [January 26, 2024, 8:06am UTC](https://forum.juce.com/t/bug-juce-ssize-t-not-being-defined-on-posix/59695/1 "2024-01-26T08:06:16Z")

</div>

I’m subclassing juce::InputStream, but i get an error on windows:

```cpp
size_t readIntoMemoryBlock (juce::MemoryBlock& destBlock,
                            ssize_t maxNumBytesToRead) override

```

because `ssize_t` being a POSIX only extension. Then JUCE got this in MathFunctions, because why not:

```cpp
#if JUCE_WINDOWS && ! JUCE_MINGW
  using ssize_t = pointer_sized_int;
#endif

```

The problem is, if i declare the method like this:

```cpp
size_t readIntoMemoryBlock (juce::MemoryBlock& destBlock,
                            juce::ssize_t maxNumBytesToRead) override

```

Now things won’t compile on posix, because the alias in the juce namespace isn’t defined.  
Should that parameter be a `std::ptrdiff_t` to be compatible with C++ on all platforms ?

As a general suggestion, never alias standard types exposed to public interfaces into your own namespace.

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [January 30, 2024, 3:21pm UTC](https://forum.juce.com/t/bug-juce-ssize-t-not-being-defined-on-posix/59695/2 "2024-01-30T15:21:44Z")

</div>

Found also this related old message with no replies

> [@Juce & Python](https://forum.juce.com/t/juce-python/15630):
>
> Dear all, I am trying to compile code that includes both JUCE and Python (using anaconda). The issue is the following: When including Python.h, it tries to load pyport.h as well. In there, there is the following: #ifdef HAVE\_SSIZE\_T typedef ssize\_t&nbsp;&nbsp; Py\_ssize\_t; #elif SIZEOF\_VOID\_P == SIZEOF\_SIZE\_T typedef Py\_\_intptr\_t&nbsp;&nbsp; Py\_ssize\_t; &nbsp; This causes a conflict with Juce, which in juce\_MathsFunctions.h calls: #if JUCE\_MSVC &nbsp; typedef pointer\_sized\_int ssize\_t; #endif &nbsp; The error is…

---

<div class="post-metadata">

**Author:** ![QuilioLtd](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/quilioltd/32/15459_2.png) [@QuilioLtd](https://forum.juce.com/u/QuilioLtd)\
**Post date:** [May 31, 2024, 9:03am UTC](https://forum.juce.com/t/bug-juce-ssize-t-not-being-defined-on-posix/59695/3 "2024-05-31T09:03:34Z")

</div>

Are you using CMake or the Projucer to set the build up?

My Projucer generated build simply doesn’t run.  
However, my CMake generated build works fine.
