Hello,
I am working on an application that may need to be run in a windows or OSX context. My workstation is a OSX 10.10 machine, and I have a personal computer with Windows 10. I am using git for source control and to move work back and forth. My question comes when I went to move code from an XCode project to a Codeblocks project. I created a new CB project and added the right addons and source files, and the compiler fails with a segmentation fault in a strange location, that does not appear when compiling under XCode. I assume this is some error in my code that XCode is fixing for me so this may not be a Codeblocks issue. Below is the section of code and the error message. Any guidance as to where I messed up would be appreciated.
OF 0.8.4
CB 12.11 Win 10
XCode 6.4 OSX 10.10
Error
D:\Code\of_v0.8.4\apps\FluidTesting\src\ParticleSystem.cpp|| In member function 'void ParticleSystem::updateWithField(ParticleField)': |
D:\Code\of_v0.8.4\apps\FluidTesting\src\ParticleSystem.cpp|39| internal compiler error: Segmentation fault|
||=== Build finished: 1 errors, 12 warnings (0 minutes, 6 seconds) ===|
ParticleSystem.cpp
void ParticleSystem::updateWithField(ParticleField field){
ofVec2f windowSize(ofGetWidth(), ofGetHeight());
for(int i=0; i<SYSTEM_SIZE; i++) {
ofVec2f val(field.getValueAtPoint(particles[i].pos));
particles[i].updateWithField(i, windowSize, posArray, colArray, val);
}
}
ParticleSystem.h
void updateWithField(ParticleField field);
Particle.h
void update(int i, const ofVec2f &windowSize, float* posArray, float * colArray);
void updateWithField(int i, const ofVec2f &windowSize,
float* posArray, float * colArray, ofVec2f fieldVal);
I am assuming this is a pointer / memory error. So I removed the pointers just to see what happened and other errors began to emerge. For example the below line gave errors about "Invalid types for array subscript" with I being declared as an integer.
posArray[i++] = pos.x - vel.x;
I guess the crux of my issue is a style guide / difference between XCode and its compiler and GCC under CodeBlocks. Is there somewhere I can research the difference and make my code more compatible? Or are these issues with my code and my knowledge of C++.
Best,
Jordan