Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

C++ compiling issue, Mac/codeblocks/GCC


ghost's Avatar
0 0

I tried to recompile my cash register program, in which I'm now implimenting a linked list to keep track of what was added to the order, and I'm getting this long list of errors. the weird thing is, that the errors aren't in files I wrote, or am using, for the most part, as far as I can tell. here's the list of errors:

/usr/include/c++/4.0.0/i686-apple-darwin9/bits/c++config.h:64: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/i686-apple-darwin9/bits/c++config.h:66: error: expected unqualified-id before 'namespace'
/usr/include/_locale.h:74: error: expected unqualified-id before string constant
/usr/include/locale.h:52: error: expected unqualified-id before string constant
/usr/include/c++/4.0.0/clocale:55: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/cstddef:50: error: expected unqualified-id before 'namespace'
/usr/include/string.h:80: error: expected unqualified-id before string constant
/usr/include/c++/4.0.0/cstring:77: error: expected unqualified-id before 'namespace'
/usr/include/stdio.h:165: error: expected unqualified-id before string constant
/usr/include/stdio.h:248: error: expected unqualified-id before string constant
/usr/include/stdio.h:307: error: expected unqualified-id before string constant
/usr/include/stdio.h:356: error: expected unqualified-id before string constant
/usr/include/stdio.h:371: error: expected unqualified-id before string constant
/usr/include/c++/4.0.0/cstdio:97: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/cstdio:153: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/cstdio:175: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/i686-apple-darwin9/bits/c++locale.h:47: error: expected unqualified-id before 'namespace'
/usr/include/sched.h:30: error: expected unqualified-id before string constant
/usr/include/time.h:113: error: storage class specified for 'tzname'
/usr/include/time.h:116: error: storage class specified for 'getdate_err'
/usr/include/time.h:118: error: storage class specified for 'timezone'
/usr/include/time.h:118: error: 'asm' specifiers are not permitted on non-static data members
/usr/include/time.h:120: error: storage class specified for 'daylight'
/usr/include/time.h:122: error: expected unqualified-id before string constant
/usr/include/pthread.h:148: error: expected unqualified-id before string constant
/usr/include/unistd.h:414: error: expected unqualified-id before string constant
/usr/include/c++/4.0.0/i686-apple-darwin9/bits/c++io.h:39: error: expected unqualified-id before 'namespace'
/usr/include/runetype.h:131: error: expected unqualified-id before string constant
/usr/include/ctype.h:145: error: expected unqualified-id before string constant
/usr/include/ctype.h:164: error: expected unqualified-id before string constant
/usr/include/ctype.h:204: error: expected unqualified-id before string constant
/usr/include/c++/4.0.0/cctype:66: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/bits/stringfwd.h:46: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/ctime:64: error: expected unqualified-id before 'namespace'
/usr/include/_wctype.h:176: error: expected unqualified-id before string constant
/usr/include/wchar.h:116: error: expected unqualified-id before string constant
/usr/include/c++/4.0.0/cwchar:69: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/cwchar:141: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/cwchar:242: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/cwchar:263: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/bits/postypes.h:52: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/bits/functexcept.h:43: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/iosfwd:52: error: expected unqualified-id before 'namespace'
/usr/include/c++/4.0.0/exception:42: error: expected unqualified-id before string constant
/usr/include/sys/signal.h:412: error: expected unqualified-id before string constant
/usr/include/sys/resource.h:235: error: expected unqualified-id before string constant
/usr/include/sys/wait.h:254: error: expected unqualified-id before string constant
/usr/include/alloca.h:35: error: expected unqualified-id before string constant
/usr/include/stdlib.h:134: error: storage class specified for '__mb_cur_max'
/usr/include/stdlib.h:144: error: expected unqualified-id before string constant
Process terminated with status 1 (0 minutes, 1 seconds)
50 errors, 0 warnings

What could cause this?


stealth-'s Avatar
Ninja Extreme
0 0

I know in python that using a imported function in the wrong way can cause errors in that file, not yours, even though the root of the problem is your file.

This might be something similar here?


ghost's Avatar
0 0

Be sure you don't have a ; after #define commands, and check to ensure you don't have () after class names.

Example:

Correct: #include <iostream> #include iostream.h

class Bogus { }

Incorrect: #include <iostream>; #include iostream.h;

class Bogus() { }


ghost's Avatar
0 0

Is this the first time you've compiled something with gcc/g++ on that machine?

Try commenting out the entire body of your code and just leave the main function and the include and see if it still has a problem.


ghost's Avatar
0 0

Without seeing the code, I am having a hard time deciding. Here's my advice:

Change the order in which you #include files –They need to be in a certain order, and if they aren't right, things go bad

And/or:

Did the program work before the linked list? Is it singly or doubly linked? If the program worked before it, and the list messed it up, I recommend using std::vector instead. It's much easier to use than a list, and I'll help you with the syntax if you'd like.

For now, until you post some code, or I think of another thing. Try those.


ynori7's Avatar
Future Emperor of Earth
0 0

Recursacro wrote: Change the order in which you #include files –They need to be in a certain order, and if they aren't right, things go bad I've never really noticed that problem. Unless you're including user-defined header files that rely on the main program to provide the necessary includes, that's probably not your problem.

Like mentioned earlier, the easiest way to figure out what your problem is is to determine where it occurs, start by commenting everything out, and then gradually uncommenting pieces until it breaks again.


ghost's Avatar
0 0

ynori7 wrote: [quote]Recursacro wrote: Change the order in which you #include files –They need to be in a certain order, and if they aren't right, things go bad I've never really noticed that problem. Unless you're including user-defined header files that rely on the main program to provide the necessary includes, that's probably not your problem.

Like mentioned earlier, the easiest way to figure out what your problem is is to determine where it occurs, start by commenting everything out, and then gradually uncommenting pieces until it breaks again. [/quote]

Yeah. Notice stdio's signature, stating stdio.h is always on top. You're absolutely right about the commenting. He just needs to find out what the problem it. Perhaps even start a new project and add the code to it bit by bit. It seems to me that the code was transferred from one comp to another, because it wasn't clearly stated when the program occurred. I wonder if it was written on Mac…


ghost's Avatar
0 0

it was written on mac (typed up and attempted to compile on same machine), and after adding the linked list (singly linked list) it stopped working. the linked list was typed up on my iPod touch, then emailed, and I copied and pasted the code, but more than half my other programs are the same story and they all work, and no, I've compiled on this machine before. I'll try the commenting thing. Also, could the fact that some of the headers were included in 3 of the files? (2 headers, and main.cpp) I'm most confused by the error in time.h unless that's included by default with stdio.h, I know I'm not including it. EDIT: fixed it, I had a curly bracket where there should have been a semicolon. now on to the other 50 bugs, after fixing the five I had…


ghost's Avatar
0 0

You fixed which one? And what ones do you have left?

I stand by what I said:

std::vector is way more maintainable than a list.


ghost's Avatar
0 0

I replaced the stray curly bracket with a semicolon, and all those errors disappeared, and I only had 4 more errors (oops, used . instead of -> 4 times), and then 30 more errors, defined a member function with different parameters than in member class, missing semicolons, misspelled variable names, the usual easy fixes. now I'm just having a linker issue. I know vectors are more maintainable, but I spent almost 8 hours writing my own linked list class, I want to use it. My linked list class can return an array containing all the values in the order they appear in the list, and can convert an array to a linked list (I think, I haven't gotten to test it yet, but it looks like it would work…)


ghost's Avatar
0 0

Linker issues are good, in your case. It means that you've nothing wrong with your actual code.

I completely understand your sentimental feelings toward the list class. I'd feel the same way. It sounds as though you've made it pretty efficient!

To solve linker errors, check your Linker settings in the project manager. I'm assuming you're using VS. If not, just check to make sure the compiler knows what libraries to use. It's not all done with just #includes. :-)

Best wishes.