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)
};