<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Wed May 22, 2013 11:30 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Wed May 22, 2013 11:30 pm</pubDate>
  <lastBuildDate>Wed May 22, 2013 11:30 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: A problem with an enum</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=105429#105429</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=68031'&gt;Xelous&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Thu Apr 19, 2012 3:49 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Hey, new member to the boards, so only just saw your post...&lt;br /&gt;
&lt;br /&gt;
I've given your problem a try, with the following basic files:&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
#ifndef STACK_H_INCLUDED&lt;br /&gt;
#define STACK_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
// Enum definition with two new&lt;br /&gt;
// values for false and true&lt;br /&gt;
// respectively&lt;br /&gt;
enum boolean &amp;#123; false2, true2 &amp;#125;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#endif // STACK_H_INCLUDED&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Stack.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int main&amp;#40;&amp;#41;&lt;br /&gt;
&amp;#123;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf&amp;#40;&amp;quot;Hello world!\n&amp;quot;&amp;#41;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&amp;#125;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
And I've used the build command:&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
g++ -Wall main.c -o out.o&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
With absolutely no issues.  As you have yourself pointed out you can not use &amp;quot;true&amp;quot; and &amp;quot;false&amp;quot; as label names for the enumeration values you define, you have the correct include.&lt;br /&gt;
&lt;br /&gt;
I however wonder, have you missed off the use of&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
#ifndef STACK_H_INCLUDED&lt;br /&gt;
#define STACK_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
And so are including the stack header more than once, and therefore, declaring the enum more than once - which you can't do?&lt;br /&gt;
&lt;br /&gt;
Let me know if you need any help.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
&lt;br /&gt;
Xel</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=105429#105429</comments>
                                        <author>Xelous</author>
                                        <pubDate>Thu Apr 19, 2012 3:49 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=105429#105429</guid>
                                      </item>
                                      <item>
                                        <title>Re: A problem with an enum</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=103842#103842</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=67058'&gt;larcky&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri Jan 13, 2012 7:53 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Is this C or C++?  C++ already has a type &lt;span style=&quot;font-style: italic&quot;&gt;bool&lt;/span&gt; which is a keyword, as are &lt;span style=&quot;font-style: italic&quot;&gt;true&lt;/span&gt; and &lt;span style=&quot;font-style: italic&quot;&gt;false&lt;/span&gt;, so you're not supposed to use any of them as identifiers.  What about calling them &lt;span style=&quot;font-style: italic&quot;&gt;true2&lt;/span&gt; and &lt;span style=&quot;font-style: italic&quot;&gt;false2&lt;/span&gt;, for example?&lt;br /&gt;
Regards, l&lt;br /&gt;
&lt;br /&gt;
*EDIT*&lt;br /&gt;
Oops, sorry, see you've just tried that.  Could you post a small test case?</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=103842#103842</comments>
                                        <author>larcky</author>
                                        <pubDate>Fri Jan 13, 2012 7:53 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=103842#103842</guid>
                                      </item>
                                      <item>
                                        <title>A problem with an enum</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=103839#103839</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=66284'&gt;stuarte9&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri Jan 13, 2012 2:50 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Hi all,&lt;br /&gt;
&lt;br /&gt;
I'm currently having a small compilation problem with an enum.&lt;br /&gt;
&lt;br /&gt;
In the C header file &amp;quot;stack.h&amp;quot; I have the following :-&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
enum boolean &amp;#123;false, true&amp;#125;;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
File &amp;quot;stack.h&amp;quot; is included in the (main) C++ file &amp;quot;test_stack.cpp&amp;quot; using the following :-&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;stack.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
When I compile &amp;quot;test_stack.cpp&amp;quot; using &amp;quot;g++ -Wall -g test_stack.cpp -o test_stack&amp;quot; I get the following error messages :-&lt;br /&gt;
&lt;br /&gt;
In file included from test_stack.cpp:5:0:&lt;br /&gt;
stack.h:8:10: error: expected identifier before ‘false’&lt;br /&gt;
stack.h:8:10: error: expected ‘}’ before ‘false’&lt;br /&gt;
stack.h:8:10: error: expected unqualified-id before ‘false’&lt;br /&gt;
stack.h:8:21: error: expected declaration before ‘}’ token&lt;br /&gt;
&lt;br /&gt;
To be clear, #include &amp;quot;stack.h&amp;quot; occurs on line 5 of &amp;quot;test_stack.cpp&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Does anyone know if a C++ program including a C header is likely to lead to just this kind of error message ? I would have thought that, as C++ is a superset of C, this would not be the case.&lt;br /&gt;
&lt;br /&gt;
Also, I just don't see anything wrong with the enum. I've tried changing boolean to &amp;quot;truth&amp;quot; and then &amp;quot;valid&amp;quot;. (I wondered if the fact that bool is a keyword in C++ was the problem.) A re-compilation in each case merely resulted in the displaying of the same error messages.&lt;br /&gt;
&lt;br /&gt;
Thanks in advance,&lt;br /&gt;
&lt;br /&gt;
Stuart</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=103839#103839</comments>
                                        <author>stuarte9</author>
                                        <pubDate>Fri Jan 13, 2012 2:50 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=103839#103839</guid>
                                      </item></channel></rss>