[Solved] C++ programs on Mac OS

A default macOS installation will include something that pretends to be gcc but that’s just a legacy concern so that portable programs will properly detect a compiler when you do a source install with the usual ./configure && make && make install or use a package manager like Homebrew. Xcode used to use gcc as … Read more

[Solved] Getting a C++ program to write to a file [closed]

It sounds like you’re saying you’re printing numbers to stdout and they’re going off the screen. Since you’re using C++ you can replace cout in your output instructions with an ofstream (output file stream) like so: #include <fstream> // … ofstream outFile(“myNums.txt”); // … outFile << myNum; An easier way if you already have the … Read more

[Solved] can not understand this SEGFAULT [closed]

Here is one issue: void WaveTableManager::insert(WaveTable * WT,int position) { if (wtvector.size()<=position) wtvector.resize(position); wtvector[position]=WT; // < — Out of bounds access } When you call resize(), the upper bound is vector::size()-1. Since position is the new size of the vector, what you probably want is this: wtvector[position – 1] = WT; 5 solved can not … Read more

[Solved] expected ‘)’ before object. class does not name a type [duplicate]

For starters, you should remove #include “Car.h” from Color.h. It creates an unnecessary circular include, and the compiler hits Car(Color a) before it knows that Color is a class. You also need to include the header <string> to output a string to cout. Next time, maybe don’t insult the people who are helping you. solved … Read more

[Solved] Copying to std::chrono::milliseconds with memcpy() gives error -Werror=class-memaccess [closed]

The safer way to implement this that doesn’t rely on knowing the internal layout of std::chrono::duration would be to copy to an integer then pass the integer to the duration: std::array<unsigned char, 6> myArray = {123, 123, 112, 0, 15}; int64_t milliseconds = 0; memcpy(&milliseconds, &myArray, 5); std::chrono::milliseconds dest{milliseconds}; 3 solved Copying to std::chrono::milliseconds with … Read more

[Solved] SDL2 Exporting to linux

Well I solved the problem i was installing wrong SDL2 libraries: used these: sudo apt-get install libsdl2-dev sudo apt-get install libsdl2-image-dev sudo apt-get install libsdl2-ttf-dev 1 solved SDL2 Exporting to linux

[Solved] missing binary operator before token “(“

You misspelled defined: #if definied(_WIN32) || definied(_WIN64) || definied(__WIN32__) #elif definied(__linux) || definied(__linux__) || definied(linux) should be: #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) #elif defined(__linux) || defined(__linux__) || defined(linux) solved missing binary operator before token “(”

[Solved] Error multiple definition when compiling using headers [closed]

Do not mix declaration with definition/instantiation in a .h file. Your are instantiating g_font, g_window and g_renderer in isolation.h file. The correct is instantiating only once, usually, in a .cpp To solve your problem, change isolation.h to declare those variables as external linkage: //load global front extern TTF_Font* g_font; //window extern SDL_Window* g_window; //renderer extern … Read more

[Solved] How is this program running in debug mode? [closed]

The source is in hw.cpp, which obviously is using some kind of argument parsing to look for ‘debug’. For example: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { if (argc > 1 && strcmp(argv[1], “debug”) == 0) printf(“Hello World\n”); return 0; } If you would like to do argument parsing more involved then … Read more