brace-enclosed error

This is a discussion on brace-enclosed error within the C++ Programming forums, part of the General Programming Boards category; Please Quzah or Salem, give me a hand here....

  1. #16
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Please Quzah or Salem, give me a hand here.

  2. #17
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Of course this is a C++ forum. But C++ incorporates C90 at least to a degree.

    Here we see that,
    The initializer for a scalar shall be a single expression, optionally enclosed in braces.
    Yet this would not appear to be what is occurring, and it does appear to be language dependent.

    Yes, you've pinpointed the issue in C++. My question was in regard to a reference to where exactly the difference might be highlighted in a C++ reference.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #18
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    You'd think after they posted the struct definition, the initialization would become obvious.

  4. #19
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >The initializer for a scalar shall be a single expression, optionally enclosed in braces.
    Well, I didn't think an array was a scalar.

  5. #20
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by swoopy View Post
    >The initializer for a scalar shall be a single expression, optionally enclosed in braces.
    Well, I didn't think an array was a scalar.
    Uh. It isn't.
    Quote Originally Posted by swoopy View Post
    It looks like you've several array initializers that aren't arrays, and thus shouldn't be enclosed in braces. For example __filler44, ___filler4, ___filler5, ___filler7, ___filler9, ___filler11, ___filler12, ___filler19, ___filler29 and ___filler32.

    Code:
    	{ 0 },		//	Byte										__filler44;
    .
    .
    	{ 0 },		//	Byte										___filler4;
    .
    .
    	{ 0 },		//	Byte										___filler5;
    .
    .
    	{ 0 },		//	Byte										___filler7;
    .
    .
    	{ 0 },		//	Byte										___filler9;
    .
    .
    	{ 0 },		//	Byte										___filler11;
    .
    .
    	{ 0 },		//	Byte										___filler12;
    .
    .
    	{ 0 },		//	Byte										___filler19;
    .
    .
    	{ 0 },		//	Byte										___filler29;
    .
    .
    	{ 0 },		//	Byte										___filler32;
    But "[y]ou'd think after they posted the struct definition" this was obvious.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  6. #21
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    But if I get what you're saying, this should compile either way. So maybe he's using:
    Code:
    gcc EmRegs328.cpp
    When he should be using:
    Code:
    g++ EmRegs328.cpp

  7. #22
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by swoopy View Post
    But if I get what you're saying, this should compile either way. So maybe he's using:
    Code:
    gcc EmRegs328.cpp
    When he should be using:
    Code:
    g++ EmRegs328.cpp
    No, I'm asking the reverse, in a way.

    S/He's compiling C++ as C++. I'm asking about the difference with C instead of C++.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #23
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    But my feeling is if you're going to use brackets, use them for all scalars, which is not the case here. But perhaps the inconsistency does not bother you.

  9. #24
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >S/He's compiling C++ as C++.
    I don't think so. Because if that was the case, then according to you, it would have compiled. Or maybe I'm missing something.

  10. #25
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Please stay on the topic you're tying a grill my butt for. This is not about consistency, it's about correctness.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  11. #26
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by swoopy View Post
    >S/He's compiling C++ as C++.
    I don't think so. Because if that was the case, then according to you, it would have compiled. Or maybe I'm missing something.
    No. It compiles in C, but not in C++.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  12. #27
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Here's my interpretation of your take. The braces are optional in C++. Thus the original code should have compiled. Correct?

  13. #28
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by swoopy View Post
    Here's my interpretation of your take. The braces are optional in C++. Thus the original code should have compiled. Correct?
    Backwards.

    The code should have compiled in C. It doesn't in C++. Can someone point me to where the difference is distinguished in the C++ standard?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  14. #29
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Quote Originally Posted by Dave_Sinkula View Post
    No. It compiles in C, but not in C++.
    So the braces for a scalar are optional in C?

  15. #30
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by swoopy View Post
    So the braces for a scalar are optional in C?
    Yes, as indicated by the title of that document.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Page 2 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21