cleanup CMAKE_CXX_FLAGS and fix various warnings

This commit is contained in:
Wolfgang Thaller 2019-01-04 03:35:32 +01:00
parent bade105326
commit 380fef0114
26 changed files with 268 additions and 272 deletions

View File

@ -22,6 +22,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE) set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=return-type -Wno-multichar")
if(CMAKE_SYSTEM_NAME MATCHES Retro.*) if(CMAKE_SYSTEM_NAME MATCHES Retro.*)

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>. # along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "-std=c++11")
add_library(RetroConsole add_library(RetroConsole
Console.cc Console.cc
@ -30,6 +29,12 @@ set_target_properties(retrocrt
PROPERTIES PROPERTIES
COMPILE_OPTIONS -ffunction-sections) COMPILE_OPTIONS -ffunction-sections)
# different library name for Carbon
# (Carbon shares the powerpc-apple-macos/ directory with Classic PPC)
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
set_target_properties(RetroConsole PROPERTIES OUTPUT_NAME RetroConsoleCarbon)
endif()
install(TARGETS RetroConsole DESTINATION lib) install(TARGETS RetroConsole DESTINATION lib)
add_application(ConsoleTest add_application(ConsoleTest

View File

@ -19,7 +19,6 @@
#include "Console.h" #include "Console.h"
#include "MacUtils.h" #include "MacUtils.h"
#include "Events.h"
#include "Fonts.h" #include "Fonts.h"
#include "Processes.h" #include "Processes.h"
@ -254,7 +253,6 @@ void Console::write(const char *p, int n)
std::string Console::ReadLine() std::string Console::ReadLine()
{ {
std::string buffer; std::string buffer;
EventRecord event;
char c; char c;
do do

View File

@ -1,5 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Werror=return-type -Wno-multichar")
find_package(Boost COMPONENTS filesystem system REQUIRED) find_package(Boost COMPONENTS filesystem system REQUIRED)
add_executable(ConvertObj ConvertObj.cc) add_executable(ConvertObj ConvertObj.cc)

View File

@ -46,6 +46,7 @@ public:
/* /*
* Recursive directory copy from https://stackoverflow.com/a/39146566 * Recursive directory copy from https://stackoverflow.com/a/39146566
*/ */
#ifdef __APPLE__
static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path& destinationDir) static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path& destinationDir)
{ {
if (!fs::exists(sourceDir) || !fs::is_directory(sourceDir)) if (!fs::exists(sourceDir) || !fs::is_directory(sourceDir))
@ -68,6 +69,7 @@ static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path&
fs::copy(path, destinationDir / relativePathStr); fs::copy(path, destinationDir / relativePathStr);
} }
} }
#endif
MiniVMacLauncher::MiniVMacLauncher(po::variables_map &options) MiniVMacLauncher::MiniVMacLauncher(po::variables_map &options)
: Launcher(options), : Launcher(options),
@ -286,6 +288,8 @@ void MiniVMacLauncher::DumpOutput()
vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDONLY); vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDONLY);
hfsdirent fileent; hfsdirent fileent;
int statres = hfs_stat(vol, "out", &fileent); int statres = hfs_stat(vol, "out", &fileent);
if(statres)
return;
hfsfile *out = hfs_open(vol, "out"); hfsfile *out = hfs_open(vol, "out");
if(!out) if(!out)

View File

@ -46,7 +46,7 @@ public:
private: private:
void write(const void *p, size_t n); void write(const void *p, size_t n);
ssize_t read(void * p, size_t n); size_t read(void * p, size_t n);
}; };
@ -140,10 +140,10 @@ SerialLauncher::~SerialLauncher()
{ {
} }
ssize_t SerialLauncher::read(void *p0, size_t n) size_t SerialLauncher::read(void *p0, size_t n)
{ {
uint8_t* p = (uint8_t*)p0; uint8_t* p = (uint8_t*)p0;
ssize_t gotBytes = rStream.read(p, n); size_t gotBytes = rStream.read(p, n);
while(gotBytes < n) while(gotBytes < n)
{ {
rStream.flushWrite(); rStream.flushWrite();

View File

@ -94,7 +94,7 @@ TCPLauncher::~TCPLauncher()
ssize_t TCPLauncher::read(void *p0, size_t n) ssize_t TCPLauncher::read(void *p0, size_t n)
{ {
uint8_t* p = (uint8_t*)p0; uint8_t* p = (uint8_t*)p0;
ssize_t gotBytes = rStream.read(p, n); size_t gotBytes = rStream.read(p, n);
while(gotBytes < n) while(gotBytes < n)
{ {
rStream.flushWrite(); rStream.flushWrite();

View File

@ -11,6 +11,6 @@ target_include_directories(LaunchAPPLCommon PUBLIC .)
add_executable(TestLaunchAPPLCommon Test.cc) add_executable(TestLaunchAPPLCommon Test.cc)
target_link_libraries(TestLaunchAPPLCommon LaunchAPPLCommon) target_link_libraries(TestLaunchAPPLCommon LaunchAPPLCommon)
if(CMAKE_SYSTEM_NAME MATCHES Retro68) if(CMAKE_SYSTEM_NAME MATCHES Retro)
#target_compile_options(LaunchAPPLCommon PRIVATE -ffunction-sections -fno-exceptions -Os) target_compile_options(LaunchAPPLCommon PRIVATE -ffunction-sections -Os)
endif() endif()

View File

@ -95,7 +95,7 @@ void ReliableStream::gotAck(uint8_t id)
if(nAcked <= sentPackets.size()) if(nAcked <= sentPackets.size())
{ {
ackedOutputPacket += nAcked; ackedOutputPacket += nAcked;
for(int i = 0; i < nAcked; i++) for(unsigned i = 0; i < nAcked; i++)
sentPackets.pop_front(); sentPackets.pop_front();
sendPackets(); sendPackets();
@ -110,7 +110,7 @@ void ReliableStream::gotNack(uint8_t id)
if(nAcked <= sentPackets.size()) if(nAcked <= sentPackets.size())
{ {
ackedOutputPacket += nAcked; ackedOutputPacket += nAcked;
for(int i = 0; i < nAcked; i++) for(unsigned i = 0; i < nAcked; i++)
sentPackets.pop_front(); sentPackets.pop_front();
sentOutputPacket = ackedOutputPacket; sentOutputPacket = ackedOutputPacket;
@ -171,8 +171,8 @@ void ReliableStream::sendOnePacket()
}; };
int match = 0, match2 = 0; int match = 0, match2 = 0;
int i; size_t i;
int consumed = 0; size_t consumed = 0;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
if(p[i] == magic1[match]) if(p[i] == magic1[match])
@ -390,8 +390,8 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
case State::skipping: case State::skipping:
{ {
int match = 0; unsigned match = 0;
int i; unsigned i;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
if(p[i] == magic1[match++]) if(p[i] == magic1[match++])
@ -401,7 +401,6 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
state = State::waiting; state = State::waiting;
return i-3; return i-3;
} }
} }
else else
match = 0; match = 0;
@ -412,9 +411,7 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
case State::receiving: case State::receiving:
{ {
int i; for(unsigned i = 0; i < n; i++)
for(i = 0; i < n; i++)
{ {
incomingPacket.push_back(p[i]); incomingPacket.push_back(p[i]);
@ -461,5 +458,5 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
} }
break; break;
} }
assert(false); std::abort(); // unreachable
} }

View File

@ -38,7 +38,7 @@ void Stream::notifyReset()
listener_->onReset(); listener_->onReset();
} }
long Stream::read(void *p, size_t n) size_t Stream::read(void *p, size_t n)
{ {
if(buffer_.size() <= n) if(buffer_.size() <= n)
{ {

View File

@ -25,7 +25,7 @@ public:
virtual void write(const void* p, size_t n) = 0; virtual void write(const void* p, size_t n) = 0;
virtual void flushWrite() {} virtual void flushWrite() {}
long read(void *p, size_t n); size_t read(void *p, size_t n);
virtual bool readyToWrite() const { return true; } virtual bool readyToWrite() const { return true; }
bool readyToRead() const { return !buffer_.empty(); } bool readyToRead() const { return !buffer_.empty(); }

View File

@ -15,7 +15,7 @@ public:
virtual void write(const void* p, size_t n) virtual void write(const void* p, size_t n)
{ {
std::cout << prefix << ": "; std::cout << prefix << ": ";
for(int i = 0; i < n; i++) for(size_t i = 0; i < n; i++)
std::cout << std::hex << std::setfill('0') << std::setw(2) << (int) ((uint8_t*)p)[i] << " "; std::cout << std::hex << std::setfill('0') << std::setw(2) << (int) ((uint8_t*)p)[i] << " ";
std::cout << std::endl; std::cout << std::endl;
other->enqueueReceive(p,n); other->enqueueReceive(p,n);
@ -45,7 +45,7 @@ public:
size_t onReceive(const uint8_t* p, size_t n) size_t onReceive(const uint8_t* p, size_t n)
{ {
std::cout << prefix; std::cout << prefix;
for(int i = 0; i < n; i++) for(size_t i = 0; i < n; i++)
{ {
if(p[i] >= 128 || p[i] < 32) if(p[i] >= 128 || p[i] < 32)
std::cout << "\\x" << std::hex << (unsigned)p[i]; std::cout << "\\x" << std::hex << (unsigned)p[i];

View File

@ -51,7 +51,7 @@ target_link_libraries(LaunchAPPLServer LaunchAPPLCommon)
set_target_properties(LaunchAPPLServer PROPERTIES set_target_properties(LaunchAPPLServer PROPERTIES
CXX_STANDARD 17 CXX_STANDARD 17
) )
target_compile_options(LaunchAPPLServer PRIVATE -ffunction-sections -Os) # -fno-exceptions target_compile_options(LaunchAPPLServer PRIVATE -ffunction-sections -Os)
if(CMAKE_SYSTEM_NAME MATCHES Retro68) if(CMAKE_SYSTEM_NAME MATCHES Retro68)
set_target_properties(LaunchAPPLServer PROPERTIES set_target_properties(LaunchAPPLServer PROPERTIES
LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/LaunchAPPLServer.segmap" LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/LaunchAPPLServer.segmap"

View File

@ -375,6 +375,9 @@ public:
state = State::launch; state = State::launch;
return count; return count;
} }
default:
return 0;
} }
} }
@ -412,8 +415,10 @@ public:
else else
{ {
connection->suspend(); connection->suspend();
#if TARGET_CPU_68K
if(void *seg = connection->segmentToUnload()) if(void *seg = connection->segmentToUnload())
UnloadSeg(seg); UnloadSeg(seg);
#endif
gPrefs.inSubLaunch = true; gPrefs.inSubLaunch = true;
WritePrefs(); WritePrefs();
@ -482,7 +487,7 @@ public:
memset(&lpb, 0, sizeof(lpb)); memset(&lpb, 0, sizeof(lpb));
lpb.reserved1 = (unsigned long) LMGetCurApName(); lpb.reserved1 = (unsigned long) LMGetCurApName();
lpb.reserved2 = 0; lpb.reserved2 = 0;
OSErr err = LaunchApplication(&lpb); LaunchApplication(&lpb);
ExitToShell(); ExitToShell();
} }
onReset(); onReset();
@ -552,6 +557,8 @@ void ConnectionChanged()
connection = std::make_unique<OpenTptConnectionProvider>(statusDisplay.get());; connection = std::make_unique<OpenTptConnectionProvider>(statusDisplay.get());;
break; break;
#endif #endif
default:
;
} }
if(connection) if(connection)
@ -599,7 +606,6 @@ int main()
#if TARGET_CPU_68K && !TARGET_RT_MAC_CFM #if TARGET_CPU_68K && !TARGET_RT_MAC_CFM
short& ROM85 = *(short*) 0x028E; short& ROM85 = *(short*) 0x028E;
Boolean is128KROM = (ROM85 > 0); Boolean is128KROM = (ROM85 > 0);
Boolean hasSysEnvirons = false;
Boolean hasWaitNextEvent = false; Boolean hasWaitNextEvent = false;
Boolean hasGestalt = false; Boolean hasGestalt = false;
Boolean hasAppleEvents = false; Boolean hasAppleEvents = false;
@ -609,11 +615,9 @@ int main()
if (is128KROM) if (is128KROM)
{ {
UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented); UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented);
UniversalProcPtr trapSysEnv = GetOSTrapAddress(_SysEnvirons);
UniversalProcPtr trapWaitNextEvent = GetToolTrapAddress(_WaitNextEvent); UniversalProcPtr trapWaitNextEvent = GetToolTrapAddress(_WaitNextEvent);
UniversalProcPtr trapGestalt = GetOSTrapAddress(_Gestalt); UniversalProcPtr trapGestalt = GetOSTrapAddress(_Gestalt);
hasSysEnvirons = (trapSysEnv != trapUnimpl);
hasWaitNextEvent = (trapWaitNextEvent != trapUnimpl); hasWaitNextEvent = (trapWaitNextEvent != trapUnimpl);
hasGestalt = (trapGestalt != trapUnimpl); hasGestalt = (trapGestalt != trapUnimpl);
@ -631,8 +635,9 @@ int main()
} }
} }
#else #else
const Boolean hasSysEnvirons = true; #if !TARGET_API_MAC_CARBON
const Boolean hasWaitNextEvent = true; const Boolean hasWaitNextEvent = true;
#endif
const Boolean hasGestalt = true; const Boolean hasGestalt = true;
const Boolean hasAppleEvents = true; const Boolean hasAppleEvents = true;
#endif #endif

View File

@ -24,12 +24,10 @@ void MacSerialStream::close()
void MacSerialStream::open() void MacSerialStream::open()
{ {
OSErr err; OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum);
err = OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum); OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum);
err = OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum);
SerSetBuf(inRefNum, inputBuffer, kInputBufferSize); SerSetBuf(inRefNum, inputBuffer, kInputBufferSize);
SerShk shk; SerShk shk;
memset(&shk, 0, sizeof(shk)); memset(&shk, 0, sizeof(shk));
shk.fCTS = true; shk.fCTS = true;

View File

@ -85,7 +85,6 @@ void OpenTptStream::write(const void* p, size_t n)
void OpenTptStream::tryReading() void OpenTptStream::tryReading()
{ {
OSStatus err;
OTResult result; OTResult result;
OTFlags flags; OTFlags flags;
do do

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>. # along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++0x")
add_executable(MakeAPPL main.cc) add_executable(MakeAPPL main.cc)
target_link_libraries(MakeAPPL ResourceFiles) target_link_libraries(MakeAPPL ResourceFiles)

View File

@ -1,5 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Werror=return-type -Wno-multichar")
find_package(Boost COMPONENTS filesystem system REQUIRED) find_package(Boost COMPONENTS filesystem system REQUIRED)
add_executable(MakePEF MakePEF.cc rs6000.h PEF.h) add_executable(MakePEF MakePEF.cc rs6000.h PEF.h)

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>. # along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++0x -Wall -Werror=return-type")
find_package(Boost COMPONENTS filesystem system REQUIRED) find_package(Boost COMPONENTS filesystem system REQUIRED)

View File

@ -17,15 +17,13 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall")
find_package(Boost COMPONENTS wave filesystem system thread regex program_options) find_package(Boost COMPONENTS wave filesystem system thread regex program_options)
# Look for bison. # Look for bison.
# We need Version 3, and Mac OS X still comes with an outdated version (2.3). # We need Version 3, and Mac OS X still comes with an outdated version (2.3).
# So we just add the path where the homebrew package manager installs its # So we just add the path where the homebrew package manager installs its
# "keg-only" version. Shouldn't hurt on Linux. # "keg-only" version. Shouldn't hurt on Linux.
set(CMAKE_PROGRAM_PATH $CMAKE_PROGRAM_PATH "/usr/local/opt/bison/bin") set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} "/usr/local/opt/bison/bin")
find_package(BISON 3.0.2) find_package(BISON 3.0.2)
if(Boost_FOUND AND BISON_FOUND) if(Boost_FOUND AND BISON_FOUND)

View File

@ -1,4 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Wno-multichar")
find_package(Boost COMPONENTS unit_test_framework) find_package(Boost COMPONENTS unit_test_framework)
add_executable(RezUnitTests UnitTests.cc) add_executable(RezUnitTests UnitTests.cc)
target_link_libraries(RezUnitTests RezLib ${Boost_LIBRARIES}) target_link_libraries(RezUnitTests RezLib ${Boost_LIBRARIES})

View File

@ -36,8 +36,6 @@ if(APPLE)
target_link_libraries(Raytracer "-framework Carbon") target_link_libraries(Raytracer "-framework Carbon")
target_link_libraries(Raytracer2 "-framework Carbon") target_link_libraries(Raytracer2 "-framework Carbon")
else() else()
set(CMAKE_CXX_FLAGS "-std=c++11")
# save 200KB of code by removing unused stuff # save 200KB of code by removing unused stuff
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections") set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections")

View File

@ -85,12 +85,12 @@ int main(int argc, char** argv)
std::cout << "Generating numbers..." << std::flush; std::cout << "Generating numbers..." << std::flush;
const int n = 1000; const size_t n = 1000;
std::vector<fixed> numbers(n); std::vector<fixed> numbers(n);
std::vector<float> floats(n); std::vector<float> floats(n);
std::vector<double> doubles(n); std::vector<double> doubles(n);
for(int i = 0; i < numbers.size(); i++) for(size_t i = 0; i < numbers.size(); i++)
{ {
numbers[i] = fixed(std::rand(), fixed::raw()); numbers[i] = fixed(std::rand(), fixed::raw());
floats[i] = float(std::rand()) / RAND_MAX; floats[i] = float(std::rand()) / RAND_MAX;

View File

@ -76,7 +76,7 @@ public:
//if(l == 0) //if(l == 0)
// return *this; // return *this;
//else //else
return (*this) * (T(1) / length()); return (*this) * (T(1) / l);
} }
#else #else
vec3<T> normalize() const { vec3<T> normalize() const {

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>. # along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "-std=c++11") # -fomit-frame-pointer")
add_application(EmptyTest EmptyTest.c) add_application(EmptyTest EmptyTest.c)

View File

@ -32,7 +32,7 @@ public:
{ {
printf("Foo::~Foo() was called. (delaying 1 sec)\n"); printf("Foo::~Foo() was called. (delaying 1 sec)\n");
long start = TickCount(); unsigned long start = TickCount();
while(TickCount() < start + 60) while(TickCount() < start + 60)
; ;
} }
@ -50,7 +50,7 @@ __attribute__((destructor))
void des() void des()
{ {
printf("des() called. (delaying 1 sec)\n"); printf("des() called. (delaying 1 sec)\n");
long start = TickCount(); unsigned long start = TickCount();
while(TickCount() < start + 60) while(TickCount() < start + 60)
; ;
} }