Error with stringstream instantiation

Hello there,

when I try to build my script with the Projucer app and I want to instantiate a simple stringstream object the compiler throws an error. Does anyone have an idea why?

Code:

#include "../JuceLibraryCode/JuceHeader.h"
#include "MyApplication.h"
#include<string> 
#include<sstream> 

class Application: public JUCEApplication
{
public:
    Application() {}
    ...
    std::stringstream ss;
    ...
}

Error:
assigning to 'basic_ostream<std::__1::basic_ios<char, std::__1::char_traits<char> >::char_type, std::__1::basic_ios<char, std::__1::char_traits<char> >::traits_type> *' (aka 'basic_ostream<char, std::__1::char_traits<char> > *') from incompatible type 'int'

in instantiation of member function 'std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_stringstream' requested here

comparison between pointer and integer ('std::__1::basic_streambuf<char, std::__1::char_traits<char> >::char_type *' (aka 'char *') and 'int')

Is it a single error or 2 errors that you are showing?
Also can you show the exact lines at which the errors occur?

And what is the content of “MyApplication.h” ?

It is basically independent on “MyApplication.h”. For this purpose, I opened a new GUI application project and just added the following three lines in the template code.

#include<string>
#include<sstream>

in the header and

std::stringstream ss;

in the body. However, I and I still get three errors when compiling with Projucer:

error: /Users/juliusrichter/Documents/Uni/Stringstream/Source/Main.cpp: assigning to 'basic_ostream<std::__1::basic_ios<char, std::__1::char_traits<char> >::char_type, std::__1::basic_ios<char, std::__1::char_traits<char> >::traits_type> *' (aka 'basic_ostream<char, std::__1::char_traits<char> > *') from incompatible type 'int'

note: /Users/juliusrichter/Documents/Uni/Stringstream/Source/Main.cpp: in instantiation of member function 'std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_stringstream' requested here

error: /Users/juliusrichter/Documents/Uni/Stringstream/Source/Main.cpp: comparison between pointer and integer ('std::__1::basic_streambuf<char, std::__1::char_traits<char> >::char_type *' (aka 'char *') and 'int')

error: /Users/juliusrichter/Documents/Uni/Stringstream/Source/Main.cpp: comparison between pointer and integer ('std::__1::basic_streambuf<char, std::__1::char_traits<char> >::char_type *' (aka 'char *') and 'int')

By the way, compiling with Xcode doesn’t generate any error.

Here is the full code.

Main.cpp:

#include "../JuceLibraryCode/JuceHeader.h"
#include "MainComponent.h"

#include<string>
#include<sstream>

class NewProjectApplication  : public JUCEApplication
{
public:
    
    NewProjectApplication() {}
    
    std::stringstream ss;
    const String getApplicationName() override       { return ProjectInfo::projectName; }
    const String getApplicationVersion() override    { return ProjectInfo::versionString; }
    bool moreThanOneInstanceAllowed() override       { return true; }

    void initialise (const String& commandLine) override
    {
        mainWindow.reset (new MainWindow (getApplicationName()));
    }

    void shutdown() override
    {
        mainWindow = nullptr; 
    }

    void systemRequestedQuit() override
    {
        quit();
    }

    void anotherInstanceStarted (const String& commandLine) override
    {
    }


    class MainWindow    : public DocumentWindow
    {
    public:
        MainWindow (String name)  : DocumentWindow (name,
                                                    Desktop::getInstance().getDefaultLookAndFeel()
                                                                          .findColour (ResizableWindow::backgroundColourId),
                                                    DocumentWindow::allButtons)
        {
            setUsingNativeTitleBar (true);
            setContentOwned (new MainComponent(), true);

           #if JUCE_IOS || JUCE_ANDROID
            setFullScreen (true);
           #else
            setResizable (true, true);
            centreWithSize (getWidth(), getHeight());
           #endif

            setVisible (true);
        }

        void closeButtonPressed() override
        {
            JUCEApplication::getInstance()->systemRequestedQuit();
        }

    private:
        JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
    };

private:
    std::unique_ptr<MainWindow> mainWindow;
};
START_JUCE_APPLICATION (NewProjectApplication)

MainComponent.h:

#pragma once

#include "../JuceLibraryCode/JuceHeader.h"

class MainComponent   : public Component
{
public:
    MainComponent();
    ~MainComponent();

    void paint (Graphics&) override;
    void resized() override;

private:
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};

MainComponent.cpp:

#pragma once

#include "../JuceLibraryCode/JuceHeader.h"

class MainComponent   : public Component
{
public:
    MainComponent();
    ~MainComponent();

    void paint (Graphics&) override;
    void resized() override;

private:
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};

I’m always compiling with XCode and didn’t know it was possible to use Projucer to compile.

Maybe something is broken with Projucer compilation? It would be usefull if you could find a way to show what command Projucer executes to compile this source (I’m not sure how to get that information) and compare with the commands issued by XCode when buillding the same source.

Which version of Xcode are you using @JuliusRichter?

I just tested the following in an even simpler console application (using JUCE v5.4.5 master):

int main (int argc, char* argv[])
{
    std::stringstream ss;
    return 0;
}

The Projucer compiler uses files from within the Xcode bundle so there may be a problem with files from certain versions not being compatible for some reason.

If I try to compile with the Projucer when the version of Xcode at /Applications/Xcode is 9.x the compilation fails, but if Xcode is version 11.x then everything compiles fine.