diff --git a/AutomatedTests/Empty.c b/AutomatedTests/Empty.c index fef951aee0..f10eda961f 100644 --- a/AutomatedTests/Empty.c +++ b/AutomatedTests/Empty.c @@ -1,4 +1,4 @@ -int main() +int main(void) { // Test: do things work well enough for us to get to main()? return 0; diff --git a/AutomatedTests/File.c b/AutomatedTests/File.c index 0608477c1d..678fed6cb3 100644 --- a/AutomatedTests/File.c +++ b/AutomatedTests/File.c @@ -1,6 +1,6 @@ #include "Test.h" -int main() +int main(void) { TEST_LOG_OK(); } diff --git a/AutomatedTests/Log.c b/AutomatedTests/Log.c index 5a0396641b..b65eedd43e 100644 --- a/AutomatedTests/Log.c +++ b/AutomatedTests/Log.c @@ -2,7 +2,7 @@ char readWriteData[6] = "Three"; -int main() +int main(void) { // constant initialized data TEST_LOG_SIZED("One",3); diff --git a/AutomatedTests/PCRel32.c b/AutomatedTests/PCRel32.c index 3e040fad4f..579cf10b88 100644 --- a/AutomatedTests/PCRel32.c +++ b/AutomatedTests/PCRel32.c @@ -6,7 +6,7 @@ __attribute__((noinline)) static void* foo(size_t x) return malloc(x); } -int main() +int main(void) { if(*(short*)&foo != 0x60FF) { diff --git a/AutomatedTests/PascalTrap.c b/AutomatedTests/PascalTrap.c index 038708ea42..b2424b7346 100644 --- a/AutomatedTests/PascalTrap.c +++ b/AutomatedTests/PascalTrap.c @@ -1,12 +1,12 @@ #include #include "Test.h" -short calc() +short calc(void) { return FixRound(FixRatio(42,5)); } -int main() +int main(void) { if(calc() == 8) TEST_LOG_OK(); diff --git a/AutomatedTests/ReallyEmpty.c b/AutomatedTests/ReallyEmpty.c index 4f1d76dec6..0a0c3a6187 100644 --- a/AutomatedTests/ReallyEmpty.c +++ b/AutomatedTests/ReallyEmpty.c @@ -1,4 +1,4 @@ -void _start() +void _start(void) { // Test: do things work well enough for us to get to a startup function? // Note: this won't work for multisegment 68K apps, as the startup function will be in the wrong segment. diff --git a/AutomatedTests/Segment1.c b/AutomatedTests/Segment1.c index 7c8bbed974..4aeaf542e1 100644 --- a/AutomatedTests/Segment1.c +++ b/AutomatedTests/Segment1.c @@ -5,8 +5,8 @@ int variable; -void Foo(); -void Bar(); +void Foo(void); +void Bar(void); Boolean Test(Boolean unloadFoo, Boolean unloadBar, Boolean compact) { @@ -36,7 +36,7 @@ Boolean Test(Boolean unloadFoo, Boolean unloadBar, Boolean compact) return true; } -int main() +int main(void) { Size grow, maxblock, maxblock2, freemem, freemem2; diff --git a/AutomatedTests/Segment2.c b/AutomatedTests/Segment2.c index 1aa70db779..0f575b1e2b 100644 --- a/AutomatedTests/Segment2.c +++ b/AutomatedTests/Segment2.c @@ -1,11 +1,11 @@ extern int variable; #include -void Foo() +void Foo(void) { variable *= 9; } -void Bar() +void Bar(void) { variable /= 9; variable *= 7; diff --git a/AutomatedTests/StdIO.c b/AutomatedTests/StdIO.c index 2c3442c5f3..faa659f69d 100644 --- a/AutomatedTests/StdIO.c +++ b/AutomatedTests/StdIO.c @@ -1,6 +1,6 @@ #include -int main() +int main(void) { FILE *f = fopen("out", "w"); fprintf(f, "OK\n"); diff --git a/AutomatedTests/Timeout.c b/AutomatedTests/Timeout.c index 3a5dc145b7..642fbbdd3d 100644 --- a/AutomatedTests/Timeout.c +++ b/AutomatedTests/Timeout.c @@ -1,6 +1,6 @@ #include "Test.h" -int main() +int main(void) { TEST_LOG_SIZED("One",3); TEST_LOG_SIZED("Two",3); diff --git a/AutomatedTests/ZeroInitialized.c b/AutomatedTests/ZeroInitialized.c index 82fd0c570d..c10fe9643b 100644 --- a/AutomatedTests/ZeroInitialized.c +++ b/AutomatedTests/ZeroInitialized.c @@ -8,7 +8,7 @@ int commonSymbol; int zeroInited = 0; EventRecord e; -int main() +int main(void) { int i; if(commonSymbol) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbbf80547e..bd0d8dbca1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=return-type -Wno-multichar") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror=return-type -Werror=strict-prototypes -Wno-multichar") enable_testing() diff --git a/ConvertObj/ConvertObj.cc b/ConvertObj/ConvertObj.cc index f026c7f9c0..11ce034239 100644 --- a/ConvertObj/ConvertObj.cc +++ b/ConvertObj/ConvertObj.cc @@ -56,7 +56,7 @@ enum ReferenceFlags { // flags field of kReference kUnknownReferenceFlags = 0x6E // rather a lot, isn't it? // The following flags are known to exist from DumpOBJ, - // but their value is unkown as I haven't actually seen them yet: + // but their value is unknown as I haven't actually seen them yet: // k32BitOffsets (default k16BitOffsets) }; diff --git a/Elf2Mac/LdScript.cc b/Elf2Mac/LdScript.cc index a28e584d90..45fc65e3a9 100644 --- a/Elf2Mac/LdScript.cc +++ b/Elf2Mac/LdScript.cc @@ -20,11 +20,13 @@ #include "Elf2Mac.h" #include "SegmentMap.h" +#include #include -#include -#include +#include #include +#include + using std::string; const char * scriptStart = R"ld(/* ld script for Elf2Mac */ @@ -214,7 +216,11 @@ void SegmentInfo::WriteFiltersKeep(std::ostream &out, string section) void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint) { - out << "\t.code" << id << " : {\n"; + std::ostringstream ss; + ss << std::setw(5) << std::setfill('0') << id; + const std::string zero_padded_id = ss.str(); + + out << "\t.code" << zero_padded_id << " : {\n"; out << "\t\tFILL(0x4E71);\n"; if(id == 1) { @@ -259,7 +265,7 @@ void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint) if(id == 1) out << "\t\t__EH_FRAME_BEGIN__" << " = .;\n"; else - out << "\t\t__EH_FRAME_BEGIN__" << id << " = .;\n"; + out << "\t\t__EH_FRAME_BEGIN__" << zero_padded_id << " = .;\n"; WriteFiltersKeep(out, ".eh_frame"); out << "\t\tLONG(0);\n"; WriteFiltersKeep(out, ".gcc_except_table"); @@ -278,7 +284,7 @@ void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint) FILL(0); . += 32; LONG(__EH_FRAME_BEGIN__@N@ - .); -)ld", "@N@", boost::lexical_cast(id)); +)ld", "@N@", zero_padded_id); } out << "\t}\n"; diff --git a/Elf2Mac/Object.cc b/Elf2Mac/Object.cc index a8c5a4ad5b..7feba0a40b 100644 --- a/Elf2Mac/Object.cc +++ b/Elf2Mac/Object.cc @@ -29,11 +29,12 @@ #include #include #include -#include +#include #include +#include +#include #include -#include #include "ResourceFork.h" #include "BinaryIO.h" @@ -315,7 +316,12 @@ void Object::MultiSegmentApp(string output, SegmentMap& segmentMap) string exceptionInfoMarker = "__EH_FRAME_BEGIN__"; if(id != 1) - exceptionInfoMarker += boost::lexical_cast(id); + { + std::ostringstream ss; + ss << std::setw(5) << std::setfill('0') << id; + const std::string zero_padded_id = ss.str(); + exceptionInfoMarker += zero_padded_id; + } int exceptionInfoSym = symtab->FindSym(exceptionInfoMarker); if(exceptionInfoSym != -1) { diff --git a/README.md b/README.md index 41a76bf56a..9652577e2c 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,12 @@ For Arch Linux, this should do the trick: On a Mac, get the homebrew package manager and: - brew install boost cmake gmp mpfr libmpc bison + brew install boost cmake gmp mpfr libmpc bison texinfo You can also run Retro68 on a PowerMac G4 or G5 running Mac OS 10.4 (Tiger). In that case, get the tigerbrew package manager and - brew install gcc cmake gmp mpfr libmpc bison + brew install gcc cmake gmp mpfr libmpc bison texinfo brew install boost --c++11 ### Apple Universal Interfaces vs. Multiversal Interfaces diff --git a/Samples/Dialog/dialog.c b/Samples/Dialog/dialog.c index 9d586cd36b..3177e670be 100644 --- a/Samples/Dialog/dialog.c +++ b/Samples/Dialog/dialog.c @@ -42,7 +42,7 @@ pascal void ButtonFrameProc(DialogRef dlg, DialogItemIndex itemNo) FrameRoundRect(&box,16,16); } -int main() +int main(void) { #if !TARGET_API_MAC_CARBON InitGraf(&qd.thePort); diff --git a/Samples/Launcher/Launcher.c b/Samples/Launcher/Launcher.c index 86c127a8a4..f2d54915c0 100644 --- a/Samples/Launcher/Launcher.c +++ b/Samples/Launcher/Launcher.c @@ -26,7 +26,7 @@ #include -void Explain() +void Explain(void) { printf("*********************************************************\n"); printf("This program is intended to make developing software\n"); @@ -41,7 +41,7 @@ void Explain() printf("*********************************************************\n"); } -void EjectOldDisk() +void EjectOldDisk(void) { Handle h = GetResource('LNCH', 128); if(h) @@ -55,7 +55,7 @@ void EjectOldDisk() } } -int main() +int main(void) { Explain(); EjectOldDisk(); diff --git a/Samples/MPWTool/main.c b/Samples/MPWTool/main.c index 4ec66f9ae6..2dcffece68 100644 --- a/Samples/MPWTool/main.c +++ b/Samples/MPWTool/main.c @@ -48,12 +48,12 @@ struct MPWFile; struct fsysTable { - void (*quit)(); - void (*access)(); + void (*quit)(void); + void (*access)(void); void (*close)(struct MPWFile *); void (*read)(struct MPWFile *); void (*write)(struct MPWFile *); - void (*ioctl)(); + void (*ioctl)(void); }; struct devtable @@ -101,7 +101,7 @@ struct pgminfo // Get MPW's magic struct -struct pgminfo2 * getPgmInfo() +struct pgminfo2 *getPgmInfo(void) { struct pgminfo *pgm0 = *(struct pgminfo**) 0x316; if(!pgm0) @@ -132,7 +132,7 @@ void _exit(int status) const int procInfo = kCStackBased | STACK_ROUTINE_PARAMETER(1, kFourByteCode); -int main() +int main(int argc, char *argv[], char *envp[]) { struct pgminfo2 *pgm = getPgmInfo(); if(pgm) @@ -152,19 +152,20 @@ int main() #if TARGET_CPU_PPC -void __do_global_dtors(); +void __do_global_dtors(void); -void __start() +void __start(void) { if(setjmp(exit_buf)) - ; + ; else { atexit(&__do_global_dtors); int result; { char *argv[2] = { "./a.out", NULL }; - result = main(1, argv); + char *envp[1] = { NULL }; + result = main(1, argv, envp); } exit(result); } @@ -174,7 +175,7 @@ void *__dso_handle = &__dso_handle; #else -void _start() +void _start(void) { RETRO68_RELOCATE(); @@ -188,7 +189,8 @@ void _start() int result; { char *argv[2] = { "./a.out", NULL }; - result = main(1, argv); + char *envp[1] = { NULL }; + result = main(1, argv, envp); } exit(result); } diff --git a/Samples/Raytracer/raytracer.c b/Samples/Raytracer/raytracer.c index 89443529af..4bdddfc4e7 100644 --- a/Samples/Raytracer/raytracer.c +++ b/Samples/Raytracer/raytracer.c @@ -157,7 +157,7 @@ float ray(int n, float x0, float y0, float z0, float dx, float dy, float dz) return v; } -int main() +int main(void) { WindowPtr win; diff --git a/Samples/SharedLibrary/application.c b/Samples/SharedLibrary/application.c index 2c1b3eec8a..c3497b69eb 100644 --- a/Samples/SharedLibrary/application.c +++ b/Samples/SharedLibrary/application.c @@ -23,7 +23,7 @@ #include "library.h" -int main() +int main(void) { // wait until computer is turned on ;-) while(!is_computer_on()) diff --git a/Samples/SharedLibrary/library.c b/Samples/SharedLibrary/library.c index 1ee0f6e390..54de69bd5b 100644 --- a/Samples/SharedLibrary/library.c +++ b/Samples/SharedLibrary/library.c @@ -25,7 +25,7 @@ #include "library.h" #include -void beep() +void beep(void) { SysBeep(20); } @@ -39,7 +39,7 @@ void beep() * Note that a function by this name was an actual, documented part * of the BeOS API. */ -Boolean is_computer_on() +Boolean is_computer_on(void) { return true; } diff --git a/Samples/SharedLibrary/library.h b/Samples/SharedLibrary/library.h index 1bf829c157..ce9624a4e9 100644 --- a/Samples/SharedLibrary/library.h +++ b/Samples/SharedLibrary/library.h @@ -19,5 +19,5 @@ #include -void beep(); -Boolean is_computer_on(); +void beep(void); +Boolean is_computer_on(void); diff --git a/Samples/SystemExtension/SystemExtension.c b/Samples/SystemExtension/SystemExtension.c index d32bd580d4..ef4cd05b4d 100644 --- a/Samples/SystemExtension/SystemExtension.c +++ b/Samples/SystemExtension/SystemExtension.c @@ -2,7 +2,7 @@ #include "ShowInitIcon.h" #include "Retro68Runtime.h" -void _start() +void _start(void) { RETRO68_RELOCATE(); Retro68CallConstructors(); diff --git a/Samples/WDEF/wdefshell.c b/Samples/WDEF/wdefshell.c index b65ca3460f..eec121e657 100644 --- a/Samples/WDEF/wdefshell.c +++ b/Samples/WDEF/wdefshell.c @@ -64,7 +64,7 @@ void MakeNewWindow(ConstStr255Param title, short procID) OffsetRect(&nextWindowRect, 15, 15); } -void InitCustomWDEF() +void InitCustomWDEF(void) { /* The 10-byte code resource stub trick. * @@ -91,7 +91,7 @@ void InitCustomWDEF() // with custom WDEFs. } -void ShowAboutBox() +void ShowAboutBox(void) { WindowRef w = GetNewWindow(128, NULL, (WindowPtr) - 1); MoveWindow(w, @@ -116,7 +116,7 @@ void ShowAboutBox() DisposeWindow(w); } -void UpdateMenus() +void UpdateMenus(void) { MenuRef m = GetMenu(kMenuFile); WindowRef w = FrontWindow(); @@ -234,7 +234,7 @@ void DoUpdate(WindowRef w) EndUpdate(w); } -int main() +int main(void) { InitGraf(&qd.thePort); InitFonts(); diff --git a/TestApps/EmptyTest.c b/TestApps/EmptyTest.c index 905869dfa3..58fe69254d 100644 --- a/TestApps/EmptyTest.c +++ b/TestApps/EmptyTest.c @@ -1,4 +1,4 @@ -int main() +int main(void) { return 0; } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 786ed204e9..172434818b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -81,7 +81,7 @@ jobs: - checkout: self submodules: true - script: | - docker run -i --name nix -v`pwd`:/src nixos/nix:2.3.12 < #include -void referenceMyMalloc() {} +void referenceMyMalloc(void) {} void *_malloc_r(struct _reent *reent_ptr, size_t sz) { diff --git a/libretro/ppcstart.c b/libretro/ppcstart.c index cc72fda7cd..fe3e96b494 100644 --- a/libretro/ppcstart.c +++ b/libretro/ppcstart.c @@ -28,9 +28,9 @@ int main(int argc, char* argv[]); -void __do_global_dtors(); +void __do_global_dtors(void); -void __start() +void __start(void) { int result; diff --git a/libretro/start.c b/libretro/start.c index 68e75663dd..90552dfff9 100644 --- a/libretro/start.c +++ b/libretro/start.c @@ -28,7 +28,7 @@ int main(int argc, char* argv[]); -void _start() +void _start(void) { RETRO68_RELOCATE(); atexit(&Retro68CallDestructors);