Issues with Inheritance and OpenCL - c++11

I am trying to port some code to linux from Windows. I have gotten pretty far, but now I am stuck on an error with inheritance. But I can't figure out what's not working. It appears that It's not importing the header, but I can't figure out why because it seems to me that is should be working.
here is the error output:
/usr/bin/c++ -DHAVE_CLOGS -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -std=c++11 -I/code/cuda/JF-Cut/src/build -I/code/cuda/JF-Cut/src/QVisualizer -I/code/cuda/clogs-install/include -I/usr/local/cuda-7.5/targets/x86_64-linux/include -isystem /opt/Qt/5.5/gcc_64/include -isystem /opt/Qt/5.5/gcc_64/include/QtWidgets -isystem /opt/Qt/5.5/gcc_64/include/QtGui -isystem /opt/Qt/5.5/gcc_64/include/QtCore -isystem /opt/Qt/5.5/gcc_64/./mkspecs/linux-g++ -fPIC -o CMakeFiles/QGCWidget.dir/Graph_Cut/QGCWidget.cpp.o -c /code/cuda/JF-Cut/src/QVisualizer/Graph_Cut/QGCWidget.cpp
In file included from /code/cuda/JF-Cut/src/QVisualizer/Graph_Cut/QGCWidget.cpp:44:0:
/code/cuda/JF-Cut/src/QVisualizer/Graph_Cut/../infrastructures/QError.h:45:11: error: ‘cl::Error’ has not been declared
using cl::Error;
^
/code/cuda/JF-Cut/src/QVisualizer/Graph_Cut/../infrastructures/QError.h:48:1: error: expected class-name before ‘{’ token
{
^
/code/cuda/JF-Cut/src/QVisualizer/Graph_Cut/../infrastructures/QError.h: In member function ‘void QError::serialize(std::ostringstream&, cl_int)’:
/home/sansomk/code/cuda/JF-Cut/src/QVisualizer/Graph_Cut/../infrastructures/QError.h:68:13: error: ‘cl::Error’ has not been declared
cl::Error::serialize(s, code);
Here is the Code for QError.h
#ifndef QERROR_H
#define QERROR_H
#ifndef __CL_ENABLE_EXCEPTIONS
#define __CL_ENABLE_EXCEPTIONS
#endif
// removed #include "../3rdParty/cl/cl_stacktrace.hpp"
#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.hpp>
#else
#include <CL/cl.hpp>
#endif
#define Q_LOGIC_ERROR -100
#define Q_INVALID_ARGUMENT -101
#define Q_LENGTH_ERROR -102
#define Q_OUT_OF_RANGE -103
#define Q_FUTURE_ERROR -104
#define Q_RUNTIME_ERROR -110
#define Q_RANGE_ERROR -111
#define Q_OVERFLOW_ERROR -112
#define Q_UNDERFLOW_ERROR -113
#define Q_SYSTEM_ERROR -114
using cl::Error;
class QError : public cl::Error
{
protected:
cl_int level_;
void serialize(std::ostringstream& s, cl_int code)
{
std::string error;
switch (code)
{
case Q_LOGIC_ERROR: error = "Q_LOGIC_ERROR"; break;
case Q_INVALID_ARGUMENT: error = "Q_INVALID_ARGUMENT"; break;
case Q_LENGTH_ERROR: error = "Q_LENGTH_ERROR"; break;
case Q_OUT_OF_RANGE: error = "Q_OUT_OF_RANGE"; break;
case Q_FUTURE_ERROR: error = "Q_FUTURE_ERROR"; break;
case Q_RUNTIME_ERROR: error = "Q_RUNTIME_ERROR"; break;
case Q_RANGE_ERROR: error = "Q_RANGE_ERROR"; break;
case Q_OVERFLOW_ERROR: error = "Q_OVERFLOW_ERROR"; break;
case Q_UNDERFLOW_ERROR: error = "Q_UNDERFLOW_ERROR"; break;
case Q_SYSTEM_ERROR: error = "Q_SYSTEM_ERROR"; break;
}
if (!error.empty()) s << " > " << error << ", ";
cl::Error::serialize(s, code);
}
public:
QError(cl_int level, cl_int err, const char * errStr = NULL) : level_(level), cl::Error(err, errStr) {}
~QError() throw() {}
cl_int level(void) const { return level_; }
virtual const char * what() throw ()
{
std::ostringstream s;
serialize(s, err_);
errStr_ = s.str();
return errStr_.c_str();
}
};
#endif // QERROR_H

In order to use cl::Error you need to define __CL_ENABLE_EXCEPTIONS.
I can see you have it there, but that file is a header file. If you include OpenCL headers somewhere else earlier in the compilation unit (.cpp) without defining __CL_ENABLE_EXCEPTIONS. Then the later includes will simply skip (due to ifdefs in the header file to avoid multiple instances of the same .h file).
What you should do for these types of global compilation defines, is declare them in the command line.
g++ ... -D__CL_ENABLE_EXCEPTIONS
That way you ensure the defines are enabled at the very beginning of the compilation.

Related

Error while building a static Linux binary (with musl-libc) that includes LuaJIT

I've cloned the LuaJIT git repo and built it with:
make STATIC_CC="musl-gcc" BUILDMODE="static"
Then, I compiled a simple Lua "hello world" script into a C header file:
luajit -b test.lua test.h
test.h:
#define luaJIT_BC_test_SIZE 52
static const unsigned char luaJIT_BC_test[] = {
27,76,74,2,10,45,2,0,3,0,2,0,4,54,0,0,0,39,2,1,0,66,0,2,1,75,0,1,0,20,72,101,
108,108,111,32,102,114,111,109,32,76,117,97,33,10,112,114,105,110,116,0
};
After that, I wrote a simple C wrapper by following the official example, test.c:
#include <stdio.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "test.h"
int main(void) {
int error;
lua_State *L = lua_open();
luaL_openlibs(L);
error = luaL_loadbuffer(L, (const char *) luaJIT_BC_test, luaJIT_BC_test_SIZE, "test") || lua_pcall(L, 0, 0, 0);
if (error) {
fprintf(stderr, "%s", lua_tostring(L, -1));
lua_pop(L, 1);
}
lua_close(L);
return 0;
}
But when I try to build it, it crashes with an error:
$ musl-gcc -static -ILuaJIT/src -LLuaJIT/src -o test test.c -lluajit
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/libgcc_eh.a(unwind-dw2-fde-dip.o): in function `_Unwind_Find_FDE':
(.text+0x1953): undefined reference to `_dl_find_object'
collect2: error: ld returned 1 exit status
It's related to libgcc, so I tried building everything with musl-clang, but still got the same error. Can someone explain what I'm missing here?
Figured it out - I needed to build LuaJIT with TARGET_XCFLAGS=-DLUAJIT_NO_UNWIND like so:
make STATIC_CC="musl-gcc" BUILDMODE="static" TARGET_XCFLAGS=-DLUAJIT_NO_UNWIND
I guess this just disables C++ exceptions support, but I'm not sure what the real implications are. Seems to work fine, for now.

How to prevent accidental emission of constexpr functions

Ben Deane mentions the throw trick, which ensures a link error when a constexpr function is used in a non-constexpr context.
Here is my take:
#include <iostream>
struct Exc;
constexpr int foo( int a )
{
if( a == 42 )
{
throw Exc{};
}
return 666;
}
int main()
{
constexpr auto ret = foo(43);
std::cout << ret << "\n";
return ret;
}
But I couldn't make it work (clang++ 3.8.1-23 and g++ 6.3.0):
$ clang++ -std=c++14 main.cpp
main.cpp:9:15: error: invalid use of incomplete type 'ExcBase'
throw ExcBase{};
^~~~~~~~~
main.cpp:3:8: note: forward declaration of 'ExcBase'
struct ExcBase;
^
1 error generated.
A comment in this thread suggests another trick:
#include <iostream>
constexpr int foo( int a )
{
if( a == 42 )
{
(void)reinterpret_cast<int>(a);
}
return 666;
}
int main()
{
constexpr auto ret = foo(43);
std::cout << ret << "\n";
return ret;
}
Which works: no errors or warnings; when the invocation is replaced with foo(42), clang returns:
$ clang++ -std=c++14 main.cpp
main.cpp:19:20: error: constexpr variable 'ret' must be initialized by a constant expression
constexpr auto ret = foo(42);
^ ~~~~~~~
main.cpp:10:15: note: reinterpret_cast is not allowed in a constant expression
(void)reinterpret_cast<int>(a);
^
main.cpp:19:26: note: in call to 'foo(42)'
constexpr auto ret = foo(42);
^
1 error generated.
Which is great. But gcc compiles the code happily in both cases. And now the question. How can a constexpr function be written in such a way, that it cannot be used in non-constexpr environments?
The problem is you actually instantiate (call constructor) a struct which is of incomplete type. This trick you talk about requires any symbol which will not be found at link time. So instead of struct you may use int:
http://coliru.stacked-crooked.com/a/3df5207827c8888c
#include <iostream>
extern int Exc;
constexpr int foo( int a )
{
if( a == 42 )
{
throw Exc;
}
return 666;
}
int main()
{
// Compiles
constexpr auto ret = foo(43);
std::cout << ret << "\n";
// This will show linker error as expected:
// /tmp/ccQfT6hd.o: In function `main':
// main.cpp:(.text.startup+0x4c): undefined reference to `Exc'
// collect2: error: ld returned 1 exit status
int nn;
std::cin >> nn;
auto ret2 = foo(nn);
return ret;
}

CMake fails to compile with GCC 6.3

CMake fails to bootstrap with GCC 6.3 installed.
The tests checking for a C++ compiler fail due to not finding stdlib.h and iostream.h which were removed in GCC 5.
Output of Bootstrap.cmk/cmake_bootstrap.log:
Try: cc
Line: cc cmake_bootstrap_39083_test.c -o cmake_bootstrap_39083_test
---------- file -----------------------
#ifdef __cplusplus
# error "The CMAKE_C_COMPILER is set to a C++ compiler"
#endif
#include<stdio.h>
#if defined(__CLASSIC_C__)
int main(argc, argv)
int argc;
char* argv[];
#else
int main(int argc, char* argv[])
#endif
{
printf("%d%c", (argv != 0), (char)0x0a);
return argc-1;
}
------------------------------------------
1
Test succeeded
Try: g++
Line: g++ -DTEST1 cmake_bootstrap_39083_test.cxx -o cmake_bootstrap_39083_test
---------- file -----------------------
#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif
class NeedCXX
{
public:
NeedCXX() { this->Foo = 1; }
int GetFoo() { return this->Foo; }
private:
int Foo;
};
int main()
{
NeedCXX c;
#ifdef TEST3
cout << c.GetFoo() << endl;
#else
std::cout << c.GetFoo() << std::endl;
#endif
return 0;
}
------------------------------------------
In file included from /usr/include/c++/6.3.0/ext/string_conversions.h:41:0,
from /usr/include/c++/6.3.0/bits/basic_string.h:5402,
from /usr/include/c++/6.3.0/string:52,
from /usr/include/c++/6.3.0/bits/locale_classes.h:40,
from /usr/include/c++/6.3.0/bits/ios_base.h:41,
from /usr/include/c++/6.3.0/ios:42,
from /usr/include/c++/6.3.0/ostream:38,
from /usr/include/c++/6.3.0/iostream:39,
from cmake_bootstrap_39083_test.cxx:3:
/usr/include/c++/6.3.0/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
^
compilation terminated.
Test failed to compile
Try: g++
Line: g++ -DTEST2 cmake_bootstrap_39083_test.cxx -o cmake_bootstrap_39083_test
---------- file -----------------------
#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif
class NeedCXX
{
public:
NeedCXX() { this->Foo = 1; }
int GetFoo() { return this->Foo; }
private:
int Foo;
};
int main()
{
NeedCXX c;
#ifdef TEST3
cout << c.GetFoo() << endl;
#else
std::cout << c.GetFoo() << std::endl;
#endif
return 0;
}
------------------------------------------
cmake_bootstrap_39083_test.cxx:5:23: fatal error: iostream.h: No such file or directory
# include <iostream.h>
^
compilation terminated.
Test failed to compile
Try: g++
Line: g++ -DTEST3 cmake_bootstrap_39083_test.cxx -o cmake_bootstrap_39083_test
---------- file -----------------------
#if defined(TEST1)
# include <iostream>
#else
# include <iostream.h>
#endif
class NeedCXX
{
public:
NeedCXX() { this->Foo = 1; }
int GetFoo() { return this->Foo; }
private:
int Foo;
};
int main()
{
NeedCXX c;
#ifdef TEST3
cout << c.GetFoo() << endl;
#else
std::cout << c.GetFoo() << std::endl;
#endif
return 0;
}
------------------------------------------
cmake_bootstrap_39083_test.cxx:5:23: fatal error: iostream.h: No such file or directory
# include <iostream.h>
^
compilation terminated.
Test failed to compile
Update:
The issue could be resolved changing the following line in cstdlib:
#include_next <stdlib.h>
To:
#include <stdlib.h>

Problems with building the gcc plugin

I am trying to build the simple gcc plugin. I am a newbie, but I want to implement more complicated plugins in the future.
I read a lot of manuals, and it seems that I did everything right, but something is wrong.
I can't build it. Every time I try to build my plugin I get an error:
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/tmp/ccjmG33v.o: In function `plugin_init':
plugin.c:(.text+0x9e): undefined reference to `register_callback'
plugin.c:(.text+0xc6): undefined reference to `register_callback'
collect2: ld returned 1 exit status
make: *** [plugin.o] Error 1
I have no idea what is wrong. I performed the same steps as described in all the manuals I found.
I have Ubuntu 12.04 with gcc-4.6.3 compiler.
I installed gcc-4.6-plugin-dev.
I even tried to build the plugin, based on gcc_4.6.4, that was carefully downloaded and built by myself. But the result is the same.
My Makefile:
PLUGINS_DIR = /usr/lib/gcc/i686-linux-gnu/4.6/plugin/include
INCLUDES = \
-I$(PLUGINS_DIR)
DEFINES = -Dbool=int -DTRUE=1 -DFALSE=0
plugin.so : plugin.o
gcc -shared -Wl,-export-dynamic -o plugin.so plugin.o
%.o : %.c
gcc $(DEFINES) $(INCLUDES) -fPIC -o $# $^
clean :
rm *.o *.so
Plugin source code:
#include <aspell.h>
#include <gcc-plugin.h>
#include <coretypes.h>
#include <diagnostic.h>
#include <gimple.h>
#include <tree.h>
#include <tree-flow.h>
#include <tree-pass.h>
#define is_alpha(c) (((c)>64 && (c)<91) || ((c)>96 && (c)<123))
int plugin_is_GPL_compatible = 1;
static AspellSpeller *speller_g;
/* Help info about the plugin if one were to use gcc's --version --help */
static struct plugin_info speller_info =
{
.version = "42",
.help = "Hahahaha yeaaaaa....",
};
static struct plugin_gcc_version speller_ver =
{
.basever = "4.6",
};
/* We don't need to run any tests before we execute our plugin pass */
static bool speller_gate(void)
{
return true;
}
static const_tree is_str_cst(const_tree node)
{
/*
const_tree str = node;
// Filter out types we are ignoring
if (TREE_CODE(str) == VAR_DECL)
{
if (!(str = DECL_INITIAL(node)))
return NULL_TREE;
else if (TREE_OPERAND_LENGTH(str))
str = TREE_OPERAND(str, 0);
}
else if (TREE_CODE(str) == ADDR_EXPR &&
TREE_OPERAND_LENGTH(str) > 0)
str = TREE_OPERAND(str, 0);
if (TREE_CODE(str) != STRING_CST &&
TREE_OPERAND_LENGTH(str) > 0)
str = TREE_OPERAND(str, 0);
if (TREE_CODE(str) != STRING_CST)
return NULL_TREE;
else
return str;
*/
}
static AspellSpeller *init_spellchecker(void)
{
/*
AspellConfig *cfg;
AspellCanHaveError *err;
// Configure and instantiate a spell checker
cfg = new_aspell_config();
aspell_config_replace(cfg, "lang", "en_US");
err = new_aspell_speller(cfg);
if (aspell_error_number(err) != 0)
{
puts(aspell_error_message(err));
return NULL;
}
return to_aspell_speller(err);
*/
}
static void spell_check(const_gimple stmt, const_tree str)
{
/*
char buf[32] = {0};
const char *data, *end;
data = TREE_STRING_POINTER(str);
printf("Spell checking string: \'%s\'\n", data);
while (*data)
{
// Skip non alphas including whitespace
while (!is_alpha(data[0]))
{
if (data[0] == '\0')
return;
++data;
}
// Find the end of the word
end = data;
while (is_alpha(end[0]))
++end;
if ((end - data) > sizeof(buf))
return;
memcpy(buf, data, end - data);
buf[end-data] = '\0';
if (!(aspell_speller_check(speller_g, buf, end - data)))
warning_at(gimple_location(stmt), 0, "%s (bad spelling)", buf);
data = end;
}
*/
}
static unsigned speller_exec(void)
{
/*
unsigned i;
const_tree str, op;
basic_block bb;
gimple stmt;
gimple_stmt_iterator gsi;
FOR_EACH_BB(bb)
for (gsi=gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi))
{
stmt = gsi_stmt(gsi);
for (i=0; i<gimple_num_ops(stmt); ++i)
if ((op = gimple_op(stmt, i)) && (str = is_str_cst(op)))
spell_check(stmt, str);
}
return 0;
*/
}
/* See tree-pass.h for a list and desctiptions for the fields of this struct */
static struct gimple_opt_pass speller_pass =
{
.pass.type = GIMPLE_PASS,
.pass.name = "speller", /* For use in the dump file */
.pass.gate = speller_gate,
.pass.execute = speller_exec, /* Pass handler/callback */
};
/* Return 0 on success or error code on failure */
int plugin_init(struct plugin_name_args *info, /* Argument infor */
struct plugin_gcc_version *ver) /* Version of GCC */
{
struct register_pass_info pass;
if (strncmp(ver->basever, speller_ver.basever, strlen("4.6")))
return -1; /* Incorrect version of gcc */
pass.pass = &speller_pass.pass;
pass.reference_pass_name = "ssa";
pass.ref_pass_instance_number = 1;
pass.pos_op = PASS_POS_INSERT_AFTER;
/* Tell gcc we want to be called after the first SSA pass */
register_callback("speller", PLUGIN_PASS_MANAGER_SETUP, NULL, &pass);
register_callback("speller", PLUGIN_INFO, NULL, &speller_info);
/* Initilize our spell checker */
if (!(speller_g = init_spellchecker()))
return -1;
return 0;
}
The commented source code contains the function calls undefined for the linker too. As I understand, the problem is the same as for the register_callback function.
Could someone help me to cope with this trouble? The good, detailed, not out-of-date, manual about gcc plugins writing would be very useful too.
Any help would be greatly appreciated.
Try changing the second last line of the Makefile to:
%.o : %.c
gcc $(DEFINES) $(INCLUDES) -fPIC -o $# -c $^
Note the "-c" that I have added which tells it to compile, but not link during this phase.
This is exactly an example found online if not mistaken. When compiling the plugin, if gcc prompts that some of the libraries are not found, rather than using -I to specify each library one by one when compiling the plugin, can we use a Makefileto specify all these directories instead? Thanks

Not getting strcpy errors on Mac while I do on Windows?

-- All of the revised code still refuses to run well, please help --
When I compile my code in Windows, I get memory errors. However on the Mac, where I initially coded this code, it works fine. I need to get this working on Windows.
It's something to do with the way I handle my char strings using strcpy that the Mac seems to be fine with (I guess it's related to gcc vs. Microsoft's way of doing things).
Here's the code for the complainers:
main.cpp
#include "Cust.h"
using namespace std;
int main (int argc, char * const argv[]) {
Cust customers[500];
char tmpString[70] = " ";
char * pch = new char[255];
string tmpAcctFN = " ";
string tmpAcctLN = " ";
ifstream input("P3_custData.txt");
for (int idx = 0; idx < 130; idx++){
input.getline(tmpString, 70, '\n');
strcpy(pch,strtok(tmpString," "),255);
customers[idx].setAcctNum(pch);
cout << pch << endl;
strcpy(pch, strtok(NULL," "));;
customers[idx].setAcctFN(pch);
cout << pch << endl;
strcpy(pch, strtok(NULL," "));;
customers[idx].setAcctLN(pch);
cout << pch << endl;
strcpy(pch, strtok(NULL," "));;
customers[idx].setCurrBalance(atol(pch));
cout << pch << endl;
strcpy(pch, strtok(NULL," "));;
customers[idx].setPIN(atoi(pch));
cout << pch << endl;
}
input.close();
return 0;
}
Cust.h
/*
* Cust.h
* Project 3
*
* Created by Anthony Glyadchenko on 11/17/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#include <iostream>
#include <string>
using namespace std;
#ifndef CUST_H
#define CUST_H
class Cust{
public:
char * getAcctNum();
void setAcctNum(char num[]);
double getCurrBalance();
void setCurrBalance(double balance);
void addToCurrBalance(double amount);
void subFromCurrBalance(double amount);
void setAcctFN(char firstName[]);
void setAcctLN(char lastName[]);
char * getAcctFN();
char * getAcctLN();
void setPIN(int pin);
int getPIN();
private:
char acctNum[255];
char acctFN[255];
char acctLN[255];
double currBalance;
int pin;
char fileName[255];
};
#endif
Cust.cpp
/*
* Cust.cpp
* Project 3
*
* Created by Anthony Glyadchenko on 11/17/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#include <fstream>
#include <string>
#include <sstream>
#include "Cust.h"
using namespace std;
char * Cust::getAcctNum(){
return acctNum;
}
void Cust::setAcctNum(char num[]){
strcpy(acctNum,num);
}
double Cust::getCurrBalance(){
return currBalance;
}
void Cust::setCurrBalance(double balance){
currBalance = balance;
}
void Cust::addToCurrBalance(double amount){
currBalance += amount;
}
void Cust::subFromCurrBalance(double amount){
currBalance -= amount;
}
void Cust::setAcctFN(char firstName[]){
strcpy(acctFN,firstName);
}
void Cust::setAcctLN(char lastName[]){
strcpy(acctLN,lastName);
}
char * Cust::getAcctFN(){
return acctFN;
}
char * Cust::getAcctLN(){
return acctLN;
}
void Cust::setPIN(int pin){
Cust::pin = pin;
}
int Cust::getPIN(){
return pin;
}
Here is my stack trace:
Index Function
--------------------------------------------------------------------------------
1 msvcr90d.dll!68d7f693()
2 [Frames below may be incorrect and/or missing, no symbols loaded for msvcr90d.dll]
*3 P3.exe!main(int argc=0, char * const * argv=0x0036fcd0)
4 P3.exe!_FreeLibrary#4()
5 P3.exe!#ILT+170(__except_handler4)()
6 kernel32.dll!75eb3677()
7 ntdll.dll!77b29d72()
8 ntdll.dll!77b29d45()
A few things to check (sorry not going to download the code):
does g++ *.c have warnings? If so fix them.
does g++ -W have warnings? If so fix them.
does g++ -W -Wall have warnings? If so fix them.
does g++ -W -Wall -Wextra have warnings? If so fix them.
does g++ -W -Wall -Wextra -ansi have warnings? If so fix them.
does g++ -W -Wall -Wextra -ansi -pedantic have warnings? If so fix them.
On microsoft try adding /W4 to the command line to turn the warning up, again fix any issues.
Odds are you are doing something "silly" and chances are that the compiler can help you catch what it is.
Edit:
From compiling your code with the flags above you will see:
Cust.h:33: error: ISO C++ forbids zero-size array ‘acctNum’
Cust.h:34: error: ISO C++ forbids zero-size array ‘acctFN’
Cust.h:35: error: ISO C++ forbids zero-size array ‘acctLN’
Cust.h:38: error: ISO C++ forbids zero-size array ‘fileName’
Cust.h:33: error: ISO C++ forbids zero-size array ‘acctNum’
Cust.h:34: error: ISO C++ forbids zero-size array ‘acctFN’
Cust.h:35: error: ISO C++ forbids zero-size array ‘acctLN’
Cust.h:38: error: ISO C++ forbids zero-size array ‘fileName’
So your code is not valid C++. You are copying a name into an array that is too small - the array has 0 elements. What you really need to do is give the arrays a size when you declare them or declare them as pointers and then use "new" to allocate the right amount of memroy.
Passing invalid buffers, buffers that are too small, etc., to strcpy results in undefined behavior - just about anything can happen. On the Mac, the problems happen but aren't apparent, while on Windows it results in a crash.
char acctNum[];
char acctFN[];
char acctLN[];
There's your problem right there. You never seem to allocate any space for these strings anywhere. The strcpy() in setAcctNum() is overflowing the bounds of that unsized array, and overwriting something else. It's pretty amazing that this compiles at all, actually.
You probably ought to be using std::string, instead - that'll make the memory management easier, at least.
Probably is your implementation of the strcpy function, which could have differences between how it is coded on the mac and how it's coded on Windows.

Resources