[BUG] juce::ssize_t not being defined on POSIX

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

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:

  using ssize_t = pointer_sized_int;

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

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.

1 Like

Found also this related old message with no replies