I'm trying to compile C and C++ files into a single executable using gcc. I've gotten my code to compile and run properly using borland and Visual Studio but I can't figure out how to get it to compile with gcc. This is what I've been trying:

gcc -c dtio.h dtio.c

g++ screen.h screen.cpp dtio.o testMain.cpp -o testM

The above does not work. I get a variety of errors that I don't get with any of the other compilers.

Is there some sort of flag I should be using for compiling this? I'm thinking I'm missing something here. Any ideas?

Note: I can post the source code if it is needed

The following are the compile errors I get:

In file included from Screen.h:12,
                 from a4test.cpp:45:
dtio.h:52:8: warning: no newline at end of file
In file included from a4test.cpp:45:
Screen.h:182:3: warning: no newline at end of file
In file included from Screen.h:12:
dtio.h:52:8: warning: no newline at end of file
Screen.h:182:3: warning: no newline at end of file
Screen.cpp:13:20: error: screen.h: No such file or directory
Screen.cpp:1319:2: warning: no newline at end of file
Screen.cpp:16: error: 'Field' has not been declared
Screen.cpp:16: error: ISO C++ forbids declaration of 'Field' with no type
Screen.cpp: In function 'int Field()':
Screen.cpp:18: error: 'row' was not declared in this scope
Screen.cpp:19: error: 'column' was not declared in this scope
Screen.cpp:20: error: 'cursorPosition' was not declared in this scope
Screen.cpp:21: error: 'width' was not declared in this scope
Screen.cpp:22: error: 'fieldVal' was not declared in this scope
Screen.cpp:23: error: 'editability' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:27: error: 'Field' is not a class or namespace
Screen.cpp:30: error: 'Field' is not a class or namespace
Screen.cpp:36: error: 'Field' is not a class or namespace
Screen.cpp:36: error: non-member function 'bool editable()' cannot have cv-qualifier
Screen.cpp:42: error: 'Field' is not a class or namespace
Screen.cpp:48: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:54: error: expected constructor, destructor, or type conversion before '::' token
Screen.cpp:57: error: 'LField' has not been declared
Screen.cpp:57: error: ISO C++ forbids declaration of 'LField' with no type
Screen.cpp: In function 'int LField()':
Screen.cpp:59: error: 'row' was not declared in this scope
Screen.cpp:60: error: 'column' was not declared in this scope
Screen.cpp:61: error: 'cursorPosition' was not declared in this scope
Screen.cpp:62: error: 'width' was not declared in this scope
Screen.cpp:63: error: 'fieldVal' was not declared in this scope
Screen.cpp:64: error: 'editability' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:68: error: 'LField' is not a class or namespace
Screen.cpp: In function 'void set(int, int, int, const char*, bool)':
Screen.cpp:71: error: 'dtioRows' was not declared in this scope
Screen.cpp:72: error: 'row' was not declared in this scope
Screen.cpp:74: error: 'row' was not declared in this scope
Screen.cpp:76: error: 'row' was not declared in this scope
Screen.cpp:79: error: 'dtioColumns' was not declared in this scope
Screen.cpp:80: error: 'column' was not declared in this scope
Screen.cpp:82: error: 'column' was not declared in this scope
Screen.cpp:84: error: 'column' was not declared in this scope
Screen.cpp:87: error: 'column' was not declared in this scope
Screen.cpp:87: error: 'dtioColumns' was not declared in this scope
Screen.cpp:88: error: 'width' was not declared in this scope
Screen.cpp:90: error: 'width' was not declared in this scope
Screen.cpp:92: error: 'width' was not declared in this scope
Screen.cpp:97: error: 'width' was not declared in this scope
Screen.cpp:99: error: 'width' was not declared in this scope
Screen.cpp:101: error: 'fieldVal' was not declared in this scope
Screen.cpp:101: error: 'width' was not declared in this scope
Screen.cpp:115: error: 'editability' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:119: error: 'LField' is not a class or namespace
Screen.cpp:119: error: ISO C++ forbids declaration of 'LField' with no type
Screen.cpp: In function 'int LField(int, int, int, const char*, bool)':
Screen.cpp:121: error: 'cursorPosition' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:125: error: 'LField' is not a class or namespace
Screen.cpp:125: error: ISO C++ forbids declaration of 'LField' with no type
Screen.cpp: In function 'int LField(int, int, int, const char*)':
Screen.cpp:127: error: 'cursorPosition' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:131: error: 'LField' is not a class or namespace
Screen.cpp:131: error: ISO C++ forbids declaration of 'LField' with no type
Screen.cpp: In function 'int LField(int, int, int)':
Screen.cpp:133: error: 'cursorPosition' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:137: error: 'LField' is not a class or namespace
Screen.cpp:137: error: expected ',' or '...' before '&' token
Screen.cpp:137: error: ISO C++ forbids declaration of 'LField' with no type
Screen.cpp:137: error: ISO C++ forbids declaration of 'LField' with no type
Screen.cpp: In function 'int LField(int)':
Screen.cpp:139: error: 'cursorPosition' was not declared in this scope
Screen.cpp:139: error: 'src' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:143: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:152: error: expected constructor, destructor, or type conversion before '&' token
Screen.cpp:166: error: 'LField' is not a class or namespace
Screen.cpp:166: error: non-member function 'bool editable()' cannot have cv-qualifier
Screen.cpp: In function 'bool editable()':
Screen.cpp:166: error: redefinition of 'bool editable()'
Screen.cpp:36: error: 'bool editable()' previously defined here
Screen.cpp:168: error: 'editability' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:171: error: 'LField' is not a class or namespace
Screen.cpp: In function 'void* data()':
Screen.cpp:171: error: redefinition of 'void* data()'
Screen.cpp:42: error: 'void* data()' previously defined here
Screen.cpp:173: error: 'fieldVal' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:176: error: 'LField' is not a class or namespace
Screen.cpp: In function 'void display()':
Screen.cpp:176: error: redefinition of 'void display()'
Screen.cpp:27: error: 'void display()' previously defined here
Screen.cpp:178: error: 'fieldVal' was not declared in this scope
Screen.cpp:178: error: 'row' was not declared in this scope
Screen.cpp:178: error: 'column' was not declared in this scope
Screen.cpp:178: error: 'width' was not declared in this scope
Screen.cpp:178: error: 'dtioDisplay' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:181: error: 'LField' is not a class or namespace
Screen.cpp: In function 'int edit()':
Screen.cpp:181: error: redefinition of 'int edit()'
Screen.cpp:30: error: 'int edit()' previously defined here
Screen.cpp:185: error: 'editability' was not declared in this scope
Screen.cpp:187: error: 'cursorPosition' was not declared in this scope
Screen.cpp:187: error: 'fieldVal' was not declared in this scope
Screen.cpp:190: error: 'fieldVal' was not declared in this scope
Screen.cpp:190: error: 'row' was not declared in this scope
Screen.cpp:190: error: 'column' was not declared in this scope
Screen.cpp:190: error: 'width' was not declared in this scope
Screen.cpp:190: error: 'cursorPosition' was not declared in this scope
Screen.cpp:190: error: 'dtioEdit' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:202: error: expected constructor, destructor, or type conversion before '::' token
Screen.cpp:208: error: 'Screen' has not been declared
Screen.cpp:208: error: ISO C++ forbids declaration of 'Screen' with no type
Screen.cpp: In function 'int Screen()':
Screen.cpp:210: error: 'fieldNum' was not declared in this scope
Screen.cpp:211: error: 'editing' was not declared in this scope
Screen.cpp:214: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:217: error: 'Screen' is not a class or namespace
Screen.cpp:217: error: expected ',' or '...' before '&' token
Screen.cpp:217: error: ISO C++ forbids declaration of 'Screen' with no type
Screen.cpp:217: error: ISO C++ forbids declaration of 'Screen' with no type
Screen.cpp: In function 'int Screen(int)':
Screen.cpp:219: error: 'editing' was not declared in this scope
Screen.cpp:219: error: 'cpy' was not declared in this scope
Screen.cpp:220: error: 'fieldNum' was not declared in this scope
Screen.cpp:225: error: 'fields' was not declared in this scope
Screen.cpp:225: error: expected primary-expression before ')' token
Screen.cpp:225: error: expected `;' before 'cpy'
Screen.cpp:227: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:231: error: 'Screen' is not a class or namespace
Screen.cpp:231: error: expected ',' or '...' before '&' token
Screen.cpp:231: error: ISO C++ forbids declaration of 'Field' with no type
Screen.cpp: In function 'int add(int)':
Screen.cpp:235: error: 'fieldNum' was not declared in this scope
Screen.cpp:237: error: 'fields' was not declared in this scope
Screen.cpp:237: error: expected primary-expression before ')' token
Screen.cpp:237: error: expected `;' before 'cpy'
Screen.cpp: At global scope:
Screen.cpp:246: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'int add(int, int, int)':
Screen.cpp:250: error: 'fieldNum' was not declared in this scope
Screen.cpp:252: error: expected `;' before 'val'
Screen.cpp:252: error: statement cannot resolve address of overloaded function
Screen.cpp:253: error: 'fields' was not declared in this scope
Screen.cpp:253: error: expected primary-expression before ')' token
Screen.cpp:253: error: expected `;' before 'val'
Screen.cpp: At global scope:
Screen.cpp:262: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'int add(int, int, int, const char*)':
Screen.cpp:266: error: 'fieldNum' was not declared in this scope
Screen.cpp:268: error: expected `;' before 'val'
Screen.cpp:268: error: statement cannot resolve address of overloaded function
Screen.cpp:269: error: 'fields' was not declared in this scope
Screen.cpp:269: error: expected primary-expression before ')' token
Screen.cpp:269: error: expected `;' before 'val'
Screen.cpp: At global scope:
Screen.cpp:278: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'int add(int, int, int, const char*, bool)':
Screen.cpp:282: error: 'fieldNum' was not declared in this scope
Screen.cpp:284: error: expected `;' before 'val'
Screen.cpp:284: error: statement cannot resolve address of overloaded function
Screen.cpp:285: error: 'fields' was not declared in this scope
Screen.cpp:285: error: expected primary-expression before ')' token
Screen.cpp:285: error: expected `;' before 'val'
Screen.cpp: At global scope:
Screen.cpp:294: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'void display(bool)':
Screen.cpp:297: error: 'dtioClear' was not declared in this scope
Screen.cpp:299: error: 'fieldNum' was not declared in this scope
Screen.cpp:300: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:303: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'void display()':
Screen.cpp:303: error: redefinition of 'void display()'
Screen.cpp:27: error: 'void display()' previously defined here
Screen.cpp:305: error: 'fieldNum' was not declared in this scope
Screen.cpp:306: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:309: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'int edit()':
Screen.cpp:309: error: redefinition of 'int edit()'
Screen.cpp:30: error: 'int edit()' previously defined here
Screen.cpp:312: error: 'editing' was not declared in this scope
Screen.cpp:315: error: 'fieldNum' was not declared in this scope
Screen.cpp:316: error: 'fields' was not declared in this scope
Screen.cpp:326: error: 'fields' was not declared in this scope
Screen.cpp:330: error: 'DOWN' was not declared in this scope
Screen.cpp:335: error: 'fieldNum' was not declared in this scope
Screen.cpp:341: error: 'UP' was not declared in this scope
Screen.cpp:347: error: 'fieldNum' was not declared in this scope
Screen.cpp:352: error: 'TAB' was not declared in this scope
Screen.cpp:357: error: 'fieldNum' was not declared in this scope
Screen.cpp:363: error: 'ENTER' was not declared in this scope
Screen.cpp:366: error: 'fieldNum' was not declared in this scope
Screen.cpp:374: error: a function call cannot appear in a constant-expression
Screen.cpp:377: error: a function call cannot appear in a constant-expression
Screen.cpp:380: error: a function call cannot appear in a constant-expression
Screen.cpp:383: error: a function call cannot appear in a constant-expression
Screen.cpp:386: error: a function call cannot appear in a constant-expression
Screen.cpp:389: error: a function call cannot appear in a constant-expression
Screen.cpp:392: error: a function call cannot appear in a constant-expression
Screen.cpp:395: error: a function call cannot appear in a constant-expression
Screen.cpp:398: error: a function call cannot appear in a constant-expression
Screen.cpp:401: error: a function call cannot appear in a constant-expression
Screen.cpp:404: error: a function call cannot appear in a constant-expression
Screen.cpp:407: error: a function call cannot appear in a constant-expression
Screen.cpp:410: error: 'ESCAPE' was not declared in this scope
Screen.cpp:413: error: 'PGUP' was not declared in this scope
Screen.cpp:416: error: 'PGDN' was not declared in this scope
Screen.cpp:429: error: 'fieldNum' was not declared in this scope
Screen.cpp:430: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:438: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'int edit(bool)':
Screen.cpp:441: error: 'editing' was not declared in this scope
Screen.cpp:444: error: 'dtioClear' was not declared in this scope
Screen.cpp:447: error: 'fieldNum' was not declared in this scope
Screen.cpp:448: error: 'fields' was not declared in this scope
Screen.cpp:458: error: 'fields' was not declared in this scope
Screen.cpp:462: error: 'DOWN' was not declared in this scope
Screen.cpp:467: error: 'fieldNum' was not declared in this scope
Screen.cpp:473: error: 'UP' was not declared in this scope
Screen.cpp:479: error: 'fieldNum' was not declared in this scope
Screen.cpp:484: error: 'TAB' was not declared in this scope
Screen.cpp:489: error: 'fieldNum' was not declared in this scope
Screen.cpp:495: error: 'ENTER' was not declared in this scope
Screen.cpp:498: error: 'fieldNum' was not declared in this scope
Screen.cpp:506: error: a function call cannot appear in a constant-expression
Screen.cpp:509: error: a function call cannot appear in a constant-expression
Screen.cpp:512: error: a function call cannot appear in a constant-expression
Screen.cpp:515: error: a function call cannot appear in a constant-expression
Screen.cpp:518: error: a function call cannot appear in a constant-expression
Screen.cpp:521: error: a function call cannot appear in a constant-expression
Screen.cpp:524: error: a function call cannot appear in a constant-expression
Screen.cpp:527: error: a function call cannot appear in a constant-expression
Screen.cpp:530: error: a function call cannot appear in a constant-expression
Screen.cpp:533: error: a function call cannot appear in a constant-expression
Screen.cpp:536: error: a function call cannot appear in a constant-expression
Screen.cpp:539: error: a function call cannot appear in a constant-expression
Screen.cpp:542: error: 'ESCAPE' was not declared in this scope
Screen.cpp:545: error: 'PGUP' was not declared in this scope
Screen.cpp:548: error: 'PGDN' was not declared in this scope
Screen.cpp:561: error: 'fieldNum' was not declared in this scope
Screen.cpp:562: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:570: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'int edit(int*, bool)':
Screen.cpp:576: error: 'dtioClear' was not declared in this scope
Screen.cpp:579: error: 'fieldNum' was not declared in this scope
Screen.cpp:580: error: 'fields' was not declared in this scope
Screen.cpp:589: error: 'fields' was not declared in this scope
Screen.cpp:593: error: 'fieldNum' was not declared in this scope
Screen.cpp:601: error: 'fields' was not declared in this scope
Screen.cpp:605: error: 'DOWN' was not declared in this scope
Screen.cpp:610: error: 'fieldNum' was not declared in this scope
Screen.cpp:616: error: 'UP' was not declared in this scope
Screen.cpp:622: error: 'fieldNum' was not declared in this scope
Screen.cpp:627: error: 'TAB' was not declared in this scope
Screen.cpp:632: error: 'fieldNum' was not declared in this scope
Screen.cpp:638: error: 'ENTER' was not declared in this scope
Screen.cpp:641: error: 'fieldNum' was not declared in this scope
Screen.cpp:649: error: a function call cannot appear in a constant-expression
Screen.cpp:652: error: a function call cannot appear in a constant-expression
Screen.cpp:655: error: a function call cannot appear in a constant-expression
Screen.cpp:658: error: a function call cannot appear in a constant-expression
Screen.cpp:661: error: a function call cannot appear in a constant-expression
Screen.cpp:664: error: a function call cannot appear in a constant-expression
Screen.cpp:667: error: a function call cannot appear in a constant-expression
Screen.cpp:670: error: a function call cannot appear in a constant-expression
Screen.cpp:673: error: a function call cannot appear in a constant-expression
Screen.cpp:676: error: a function call cannot appear in a constant-expression
Screen.cpp:679: error: a function call cannot appear in a constant-expression
Screen.cpp:682: error: a function call cannot appear in a constant-expression
Screen.cpp:685: error: 'ESCAPE' was not declared in this scope
Screen.cpp:688: error: 'PGUP' was not declared in this scope
Screen.cpp:691: error: 'PGDN' was not declared in this scope
Screen.cpp:704: error: 'fieldNum' was not declared in this scope
Screen.cpp:705: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:713: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'int edit(int*)':
Screen.cpp:719: error: 'fieldNum' was not declared in this scope
Screen.cpp:720: error: 'fields' was not declared in this scope
Screen.cpp:729: error: 'fields' was not declared in this scope
Screen.cpp:733: error: 'fieldNum' was not declared in this scope
Screen.cpp:741: error: 'fields' was not declared in this scope
Screen.cpp:745: error: 'DOWN' was not declared in this scope
Screen.cpp:750: error: 'fieldNum' was not declared in this scope
Screen.cpp:756: error: 'UP' was not declared in this scope
Screen.cpp:762: error: 'fieldNum' was not declared in this scope
Screen.cpp:767: error: 'TAB' was not declared in this scope
Screen.cpp:772: error: 'fieldNum' was not declared in this scope
Screen.cpp:778: error: 'ENTER' was not declared in this scope
Screen.cpp:781: error: 'fieldNum' was not declared in this scope
Screen.cpp:789: error: a function call cannot appear in a constant-expression
Screen.cpp:792: error: a function call cannot appear in a constant-expression
Screen.cpp:795: error: a function call cannot appear in a constant-expression
Screen.cpp:798: error: a function call cannot appear in a constant-expression
Screen.cpp:801: error: a function call cannot appear in a constant-expression
Screen.cpp:804: error: a function call cannot appear in a constant-expression
Screen.cpp:807: error: a function call cannot appear in a constant-expression
Screen.cpp:810: error: a function call cannot appear in a constant-expression
Screen.cpp:813: error: a function call cannot appear in a constant-expression
Screen.cpp:816: error: a function call cannot appear in a constant-expression
Screen.cpp:819: error: a function call cannot appear in a constant-expression
Screen.cpp:822: error: a function call cannot appear in a constant-expression
Screen.cpp:825: error: 'ESCAPE' was not declared in this scope
Screen.cpp:828: error: 'PGUP' was not declared in this scope
Screen.cpp:831: error: 'PGDN' was not declared in this scope
Screen.cpp:844: error: 'fieldNum' was not declared in this scope
Screen.cpp:845: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:853: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:865: error: 'Screen' is not a class or namespace
Screen.cpp: In function 'int remove(int)':
Screen.cpp:867: error: 'fieldNum' was not declared in this scope
Screen.cpp:871: error: 'fields' was not declared in this scope
Screen.cpp:875: error: 'fields' was not declared in this scope
Screen.cpp:877: error: 'fields' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:885: error: expected constructor, destructor, or type conversion before '&' token
Screen.cpp:892: error: expected constructor, destructor, or type conversion before '&' token
Screen.cpp:914: error: expected constructor, destructor, or type conversion before '::' token
Screen.cpp:921: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:926: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:931: error: 'HField' has not been declared
Screen.cpp:931: error: ISO C++ forbids declaration of 'HField' with no type
Screen.cpp: In function 'int HField(int, int, int, const char*, void (*)(void*))':
Screen.cpp:931: error: only constructors take base initializers
Screen.cpp:933: error: 'hh' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:936: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:941: error: 'HField' is not a class or namespace
Screen.cpp: In function 'int edit()':
Screen.cpp:941: error: redefinition of 'int edit()'
Screen.cpp:30: error: 'int edit()' previously defined here
Screen.cpp:946: error: 'fieldVal' was not declared in this scope
Screen.cpp:952: error: 'SField' has not been declared
Screen.cpp:956: error: a function call cannot appear in a constant-expression
Screen.cpp:957: error: 'hh' was not declared in this scope
Screen.cpp:966: error: 'ESCAPE' was not declared in this scope
Screen.cpp:975: error: 'hh' was not declared in this scope
Screen.cpp:975: error: 'F' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:983: error: 'VField' has not been declared
Screen.cpp:983: error: ISO C++ forbids declaration of 'VField' with no type
Screen.cpp: In function 'int VField(int, int, int, const char*, bool (*)(char*), void (*)(void*))':
Screen.cpp:983: error: only constructors take base initializers
Screen.cpp:985: error: 'v' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:988: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:993: error: 'VField' is not a class or namespace
Screen.cpp: In function 'int edit()':
Screen.cpp:993: error: redefinition of 'int edit()'
Screen.cpp:30: error: 'int edit()' previously defined here
Screen.cpp:999: error: 'fieldVal' was not declared in this scope
Screen.cpp:1003: error: 'HField' is not a class or namespace
Screen.cpp:1005: error: 'v' was not declared in this scope
Screen.cpp:1008: error: 'ESCAPE' was not declared in this scope
Screen.cpp:1012: error: 'HField' is not a class or namespace
Screen.cpp:1017: error: 'ESCAPE' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:1029: error: 'IVField' has not been declared
Screen.cpp:1029: error: ISO C++ forbids declaration of 'IVField' with no type
Screen.cpp: In function 'int IVField(int, int, int, int, bool (*)(int&), void (*)(void*))':
Screen.cpp:1029: error: only constructors take base initializers
Screen.cpp:1031: error: 'v' was not declared in this scope
Screen.cpp:1032: error: 'val' was not declared in this scope
Screen.cpp:1034: error: expected ',' or ';' before '::' token
Screen.cpp:1036: error: 'width' was not declared in this scope
Screen.cpp:1041: error: 'width' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:1047: error: 'IVField' is not a class or namespace
Screen.cpp: In function 'void* data()':
Screen.cpp:1047: error: redefinition of 'void* data()'
Screen.cpp:42: error: 'void* data()' previously defined here
Screen.cpp:1049: error: 'val' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:1052: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:1057: error: 'IVField' is not a class or namespace
Screen.cpp: In function 'int edit()':
Screen.cpp:1057: error: redefinition of 'int edit()'
Screen.cpp:30: error: 'int edit()' previously defined here
Screen.cpp:1059: error: 'val' was not declared in this scope
Screen.cpp:1062: error: expected ',' or ';' before '::' token
Screen.cpp:1066: error: 'VField' is not a class or namespace
Screen.cpp:1070: error: 'ESCAPE' was not declared in this scope
Screen.cpp:1071: error: 'IVField' is not a class or namespace
Screen.cpp:1078: error: 'v' was not declared in this scope
Screen.cpp:1080: error: 'IVField' is not a class or namespace
Screen.cpp:1087: error: 'IVField' is not a class or namespace
Screen.cpp: At global scope:
Screen.cpp:1099: error: expected constructor, destructor, or type conversion before '&' token
Screen.cpp:1113: error: 'DVField' has not been declared
Screen.cpp:1113: error: ISO C++ forbids declaration of 'DVField' with no type
Screen.cpp: In function 'int DVField(int, int, int, int, double, bool (*)(double&), void (*)(void*))':
Screen.cpp:1113: error: only constructors take base initializers
Screen.cpp:1116: error: 'dVal' was not declared in this scope
Screen.cpp:1117: error: expected ',' or ';' before '::' token
Screen.cpp:1118: error: 'j' was not declared in this scope
Screen.cpp:1119: error: 'v' was not declared in this scope
Screen.cpp:1121: error: 'width' was not declared in this scope
Screen.cpp:1126: error: 'width' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:1131: error: 'DVField' is not a class or namespace
Screen.cpp: In function 'void* data()':
Screen.cpp:1131: error: redefinition of 'void* data()'
Screen.cpp:42: error: 'void* data()' previously defined here
Screen.cpp:1133: error: 'dVal' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:1136: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:1141: error: 'DVField' is not a class or namespace
Screen.cpp: In function 'int edit()':
Screen.cpp:1141: error: redefinition of 'int edit()'
Screen.cpp:30: error: 'int edit()' previously defined here
Screen.cpp:1146: error: expected ',' or ';' before '::' token
Screen.cpp:1147: error: 'dVal' was not declared in this scope
Screen.cpp:1151: error: 'VField' is not a class or namespace
Screen.cpp:1155: error: 'ESCAPE' was not declared in this scope
Screen.cpp:1156: error: 'DVField' is not a class or namespace
Screen.cpp:1163: error: 'v' was not declared in this scope
Screen.cpp:1165: error: 'DVField' is not a class or namespace
Screen.cpp:1172: error: 'DVField' is not a class or namespace
Screen.cpp:1179: error: 'DVField' is not a class or namespace
Screen.cpp: At global scope:
Screen.cpp:1185: error: expected constructor, destructor, or type conversion before '&' token
Screen.cpp:1200: error: 'MMIField' has not been declared
Screen.cpp:1200: error: ISO C++ forbids declaration of 'MMIField' with no type
Screen.cpp: In function 'int MMIField(int, int, int, int, int, int, void (*)(void*))':
Screen.cpp:1200: error: only constructors take base initializers
Screen.cpp:1202: error: 'top' was not declared in this scope
Screen.cpp:1203: error: 'down' was not declared in this scope
Screen.cpp:1206: error: 'IVField' is not a class or namespace
Screen.cpp: At global scope:
Screen.cpp:1209: error: 'MMIField' is not a class or namespace
Screen.cpp: In function 'int edit()':
Screen.cpp:1209: error: redefinition of 'int edit()'
Screen.cpp:30: error: 'int edit()' previously defined here
Screen.cpp:1211: error: 'val' was not declared in this scope
Screen.cpp:1212: error: expected ',' or ';' before '::' token
Screen.cpp:1217: error: 'IVField' is not a class or namespace
Screen.cpp:1219: error: 'ESCAPE' was not declared in this scope
Screen.cpp:1221: error: 'IVField' is not a class or namespace
Screen.cpp:1224: error: 'down' was not declared in this scope
Screen.cpp:1224: error: 'top' was not declared in this scope
Screen.cpp:1229: error: 'MMIField' is not a class or namespace
Screen.cpp: At global scope:
Screen.cpp:1234: error: expected constructor, destructor, or type conversion before '*' token
Screen.cpp:1239: error: 'Box' has not been declared
Screen.cpp:1239: error: ISO C++ forbids declaration of 'Box' with no type
Screen.cpp: In function 'int Box(int, int, int, int, const char*)':
Screen.cpp:1239: error: only constructors take base initializers
Screen.cpp:1241: error: 'row' was not declared in this scope
Screen.cpp:1242: error: 'column' was not declared in this scope
Screen.cpp:1243: error: 'width' was not declared in this scope
Screen.cpp:1244: error: 'height' was not declared in this scope
Screen.cpp:1251: error: 'perimeter' was not declared in this scope
Screen.cpp:1257: error: 'perimeter' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:1269: error: 'Box' is not a class or namespace
Screen.cpp: In function 'void display()':
Screen.cpp:1269: error: redefinition of 'void display()'
Screen.cpp:27: error: 'void display()' previously defined here
Screen.cpp:1272: error: 'row' was not declared in this scope
Screen.cpp:1272: error: 'column' was not declared in this scope
Screen.cpp:1272: error: 'dtioCursor' was not declared in this scope
Screen.cpp:1273: error: 'perimeter' was not declared in this scope
Screen.cpp:1273: error: 'dtioPutchar' was not declared in this scope
Screen.cpp:1276: error: 'width' was not declared in this scope
Screen.cpp:1283: error: 'width' was not declared in this scope
Screen.cpp:1287: error: 'height' was not declared in this scope
Screen.cpp:1294: error: 'height' was not declared in this scope
Screen.cpp: At global scope:
Screen.cpp:1316: error: expected constructor, destructor, or type conversion before '*' token

One thing I see quickly is the following error,
"warning: no newline at end of file".
When you take a pc edited file to a unix envoironment or vice versa you need to understand that the characters used for end of lines are different.
Depending on your pc editor you can set the "file mode settings" to save the file in the "correct format" for unix.

hmm, so you think that could be causing the errors?

> gcc -c dtio.h dtio.c
> g++ screen.h screen.cpp dtio.o testMain.cpp -o testM
You DON'T compile header files!

gcc -c dtio.c
g++ -o testM dtio.o screen.cpp testMain.cpp

oops, go salem

> gcc -c dtio.h dtio.c
> g++ screen.h screen.cpp dtio.o testMain.cpp -o testM
You DON'T compile header files!

gcc -c dtio.c
g++ -o testM dtio.o screen.cpp testMain.cpp

Thanks for the reply Salem. I tried your suggestion but I get the same type of errors. So does that mean that problem is with my code and not the way I'm compiling it?

Posting a relevant part of screen.h, and the first 20 or so lines of screen.cpp.

> So does that mean that problem is with my code and not the way I'm compiling it?
Perhaps. Most compilers allow you to compile all sorts of non-standard crud. Which doesn't help when you move to another compiler.
It's only when you enable "strict" mode on all of them that you have some reasonable chance of portability.

> I've gotten my code to compile and run properly using borland and Visual Studio
Which versions?

VC6 for example is now a pretty poor C++ compiler (it came out before the standard, and that was over 10 years ago).
Most modern compilers find plenty to moan about with code which "worked" for VC6.

Posting a relevant part of screen.h, and the first 20 or so lines of screen.cpp.

> So does that mean that problem is with my code and not the way I'm compiling it?
Perhaps. Most compilers allow you to compile all sorts of non-standard crud. Which doesn't help when you move to another compiler.
It's only when you enable "strict" mode on all of them that you have some reasonable chance of portability.

> I've gotten my code to compile and run properly using borland and Visual Studio
Which versions?

VC6 for example is now a pretty poor C++ compiler (it came out before the standard, and that was over 10 years ago).
Most modern compilers find plenty to moan about with code which "worked" for VC6.

I'm using borland C++ 5.5.1 and Visual Studio 2005 to compile my program.

I'm not sure if this is what the errors indicate, but have you properly wrapped your C declarations like so:

#ifdef __cplusplus
extern "C"
{
#endif

int cfunc1( int n );
int cfunc2( int n );

#ifdef __cplusplus
}
#endif

I'm not sure if this is what the errors indicate, but have you properly wrapped your C declarations like so:

#ifdef __cplusplus
extern "C"
{
#endif

int cfunc1( int n );
int cfunc2( int n );

#ifdef __cplusplus
}
#endif

Yes, I have done that

ok, I managed to remove all the major errors that I was getting with Screen.cpp by changing #include "screen.h" to #include "Screen.h" But I still get errors:

In file included from Screen.h:12,
                 from Screen.cpp:13:
dtio.h:52:8: warning: no newline at end of file
In file included from Screen.cpp:13:
Screen.h:182:3: warning: no newline at end of file
In file included from Screen.h:12,
                 from a4test.cpp:45:
dtio.h:52:8: warning: no newline at end of file
In file included from a4test.cpp:45:
Screen.h:182:3: warning: no newline at end of file
dtio.o: In function `dtioStart':
dtio.c:(.text+0x7): undefined reference to `initscr'
dtio.c:(.text+0xc): undefined reference to `noecho'
dtio.c:(.text+0x11): undefined reference to `cbreak'
dtio.c:(.text+0x16): undefined reference to `stdscr'
dtio.c:(.text+0x26): undefined reference to `keypad'
dtio.o: In function `dtioClear':
dtio.c:(.text+0x33): undefined reference to `stdscr'
dtio.c:(.text+0x3b): undefined reference to `werase'
dtio.o: In function `dtioRows':
dtio.c:(.text+0x45): undefined reference to `LINES'
dtio.o: In function `dtioColumns':
dtio.c:(.text+0x4f): undefined reference to `COLS'
dtio.o: In function `dtioCursor':
dtio.c:(.text+0x5c): undefined reference to `stdscr'
dtio.c:(.text+0x72): undefined reference to `wmove'
dtio.o: In function `dtioPutchar':
dtio.c:(.text+0x83): undefined reference to `stdscr'
dtio.c:(.text+0x8f): undefined reference to `waddch'
dtio.o: In function `dtioPuts':
dtio.c:(.text+0x9d): undefined reference to `stdscr'
dtio.c:(.text+0xb4): undefined reference to `waddnstr'
dtio.o: In function `dtioGetchar':
dtio.c:(.text+0xc1): undefined reference to `stdscr'
dtio.c:(.text+0xc9): undefined reference to `wrefresh'
dtio.c:(.text+0xce): undefined reference to `stdscr'
dtio.c:(.text+0xd6): undefined reference to `wgetch'
dtio.o: In function `dtioStop':
dtio.c:(.text+0x216): undefined reference to `stdscr'
dtio.c:(.text+0x21e): undefined reference to `wrefresh'
dtio.c:(.text+0x223): undefined reference to `endwin'
dtio.o: In function `dtioMenu':
dtio.c:(.text+0xb9d): undefined reference to `stdscr'
dtio.c:(.text+0xbb3): undefined reference to `wmove'
dtio.c:(.text+0xbbd): undefined reference to `stdscr'
dtio.c:(.text+0xbc5): undefined reference to `winch'
dtio.c:(.text+0xfd9): undefined reference to `stdscr'
dtio.c:(.text+0xff1): undefined reference to `wmove'
collect2: ld returned 1 exit status

Any ideas why these errors would occur?

> dtio.h:52:8: warning: no newline at end of file
This is dead easy to fix. Just open it in the editor, goto the end of the file, press enter and save.

> dtio.c:(.text+0x7): undefined reference to `initscr'
These are all linker errors. Which in this case means you're missing a library.
From experience, you're missing the ncurses library.

Perhaps something like

gcc -c dtio.c
g++ -o testM dtio.o screen.cpp testMain.cpp -lncurses

Assuming you have it installed.

> dtio.h:52:8: warning: no newline at end of file
This is dead easy to fix. Just open it in the editor, goto the end of the file, press enter and save.

> dtio.c:(.text+0x7): undefined reference to `initscr'
These are all linker errors. Which in this case means you're missing a library.
From experience, you're missing the ncurses library.

Perhaps something like

gcc -c dtio.c
g++ -o testM dtio.o screen.cpp testMain.cpp -lncurses

Assuming you have it installed.

Great advice Salem! Thanks a ton to all of you that helped. It works now :)

Marking this thread as solved

you should try compiling each of the files into object code,
something like
g++ -c yourfile.cpp
This should check if your compiler is workings,
not the crosscompilation linker and all that stuff.

To salem.
you can compile headers,
these are called .pch og h.gch
stdafx on visual studio is an example of a precompiled header.

> stdafx on visual studio is an example of a precompiled header.
But YOU don't compile them do you?
You have #include "file.h"
And if you turn on the thing, then the compiler will generate for you a file.pch, and use that instead of parsing file.h each time.

But you DON'T have to edit your project to make that happen.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.