I'm struggling to compile and run a program on Mac OS X, which is written using ANSI/ISO C++ (Windows). Source code
I've tried to compile using g++, and by importing the files and compiling using Xcode.
If i try to compile using g++ (command line), I get a couple of warning, which are easy to fix,:
e.g. warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
.
But, i get some weird errors as well.
If i create a simple "Command Line Tool" project of Type "C++ stdc++", and import all the files in this project, it gives me a bunch of warnings and an error.
Can anyone please help me compile this sample source code? Thanking in anticipation.
- In stopwatch.cpp change the include at line 49 from strstream.h to sstream.
- In stopwatch.cpp line 50 change the include from fstream.h to fstream.
- In qsort.h change the declaration of
Qsort()
so the second and third parameters are unsigned long
rather than size_t
.
- In qsort.cpp change the definition of
Qsort()
so the second and third parameters are unsigned long
rather than unsigned
.
As a side note, the declaration and the definition of Qsort()
didn't (necessarily) match in signature, and that's incorrect.
In qsort.cpp change the function decleration to:
52 void __cdecl Qsort (
53 void *base,
54 unsigned long num,
55 unsigned long width,
56 int (__cdecl *comp)(const void *, const void *)
57 )
So we just added long
to num
and width
variables.
You will also have to fix simple problems like #include <strstream.h>
-> #include <strsream>