Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirasawaSama committed Oct 24, 2023
1 parent 021883f commit ef84b64
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_definitions(-DJUCE_USE_MP3AUDIOFORMAT -DJUCE_PLUGINHOST_VST3 -DJUCE_PLUGINHO

if(MSVC)
add_definitions(-DJUCE_PLUGINHOST_VST -DJUCE_ASIO)
endif(MSVC)
endif()

file(GLOB EIM_SRC_FILES "src/*.cpp" "src/*.h")

Expand All @@ -26,7 +26,9 @@ juce_add_console_app(${PROJECT_NAME}
)
set_target_properties(${PROJECT_NAME} PROPERTIES JUCE_TARGET_KIND_STRING "App")
_juce_configure_bundle(${PROJECT_NAME} ${PROJECT_NAME})
_juce_configure_app_bundle(${PROJECT_NAME} ${PROJECT_NAME})
if(NOT MSVC)
_juce_configure_app_bundle(${PROJECT_NAME} ${PROJECT_NAME})
endif()

target_sources(${PROJECT_NAME} PRIVATE ${EIM_SRC_FILES})
target_compile_definitions(${PROJECT_NAME} PRIVATE JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0)
Expand Down Expand Up @@ -62,7 +64,7 @@ if(MSVC)
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif(MSVC)
endif()

target_compile_definitions(${PROJECT_NAME}
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int main(int argc, char* argv[]) {
juce::JUCEApplicationBase::main(argc, (const char**)argv);
} else if (args->containsOption("-O|--output")) {
#ifdef JUCE_WINDOWS
CoInitialize(nullptr);
juce::ignoreUnused(CoInitialize(nullptr));
#endif

juce::initialiseJuce_GUI();
Expand Down
14 changes: 9 additions & 5 deletions src/utils.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef EIM_UTILS_H
#define EIM_UTILS_H

#ifdef _WIN32
#ifdef JUCE_WINDOWS
#include <io.h>
#endif

Expand All @@ -20,8 +20,8 @@ namespace eim {
output_stream() {
setvbuf(oldStdout, nullptr, _IOFBF, 4096);
juce::ignoreUnused(freopen(nullptr, "wb", oldStdout));
#ifdef _WIN32
_setmode(_fileno(oldStdout), _O_BINARY);
#ifdef JUCE_WINDOWS
juce::ignoreUnused(_setmode(_fileno(oldStdout), _O_BINARY));
#endif
}

Expand Down Expand Up @@ -84,16 +84,20 @@ namespace eim {
static void preventStdout() { juce::ignoreUnused(freopen("/dev/null", "w", stdout)); }

private:
#ifdef JUCE_WINDOWS
FILE* oldStdout = _fdopen(_dup(1), "wb");
#else
FILE *oldStdout = fdopen(dup(1), "wb");
#endif
};

class input_stream {
public:
input_stream() {
setvbuf(stdin, nullptr, _IOFBF, 4096);
juce::ignoreUnused(freopen(nullptr, "rb", stdin));
#ifdef _WIN32
_setmode(_fileno(stdin), _O_BINARY);
#ifdef JUCE_WINDOWS
juce::ignoreUnused(_setmode(_fileno(stdin), _O_BINARY));
#endif
}

Expand Down

0 comments on commit ef84b64

Please sign in to comment.