Hi,
Can anyone point me to a complete, compilable example
of Besser's ENUM++ mechanism? I downloaded it from
CUJ and gave it a try but got errors just trying to compile
the header enum.h.
--Randy Yates 10 3902
PS: Here's what I get. This is using gcc under fc3.
--RY
#include "enum.h"
int main(int argc, char **argv)
{
return 0;
}
cd /home/yates/modetest/host/app/modetest/
make -f enumpp.mak TARGET=native PLATFORM=linux
DSPROOT_DIR=/home/yates/modetest/ ATSIGN=
enumpp.mak:101: no file name for `include'
Building Component (enumpp) for Application enumpp
In file included from
/home/yates/modetest/host/app/modetest/enum.h:202,
from
/home/yates/modetest/host/app/modetest/enumpp.cpp:1:
/home/yates/modetest/host/app/modetest/StreamUDT.h: In function
`std::basic_ost ream<_CharT, _Traits>&
KEA::stream_ins erter(std::basi c_ostream<_Char T, _Traits>&, const
UDT&)':
/home/yates/modetest/host/app/modetest/StreamUDT.h:96: error: expected
`;' before "prepost"
/home/yates/modetest/host/app/modetest/StreamUDT.h:97: error: `prepost'
undeclared (first use this function)
/home/yates/modetest/host/app/modetest/StreamUDT.h:97: error: (Each
undeclared identifier is reported only once for each function it
appears in.)
/home/yates/modetest/host/app/modetest/StreamUDT.h: In function
`std::basic_ist ream<_CharT, _Traits>&
KEA::stream_ext ractor(std::bas ic_istream<_Cha rT, _Traits>&, UDT&)':
/home/yates/modetest/host/app/modetest/StreamUDT.h:151 : error: expected
`;' before "prepost"
/home/yates/modetest/host/app/modetest/StreamUDT.h:152 : error:
`prepost' undeclared (first use this function)
In file included from
/home/yates/modetest/host/app/modetest/enumpp.cpp:1:
/home/yates/modetest/host/app/modetest/enum.h: At global scope:
/home/yates/modetest/host/app/modetest/enum.h:257: error: ISO C++
forbids declaration of `value_type' with no type
/home/yates/modetest/host/app/modetest/enum.h:257: error:
`::value_type' is not a valid declarator
/home/yates/modetest/host/app/modetest/enum.h:257: error: expected `;'
before "value_type "
/home/yates/modetest/host/app/modetest/enum.h:264: error: ISO C++
forbids declaration of `result_type' with no type
/home/yates/modetest/host/app/modetest/enum.h:264: error: expected `;'
before "operator"
/home/yates/modetest/host/app/modetest/enum.h:334: error: expected `;'
before '}' token
/home/yates/modetest/host/app/modetest/enum.h:338: error: ISO C++
forbids declaration of `result_type' with no type
/home/yates/modetest/host/app/modetest/enum.h:338: error: expected `;'
before "operator"
/home/yates/modetest/host/app/modetest/enum.h:344: error: expected `;'
before '}' token
/home/yates/modetest/host/app/modetest/enum.h:387: error: ISO C++
forbids declaration of `size_type' with no type
/home/yates/modetest/host/app/modetest/enum.h:387: error: `::size_type'
is not a valid declarator
/home/yates/modetest/host/app/modetest/enum.h:387: error: expected `;'
before "max_length "
/home/yates/modetest/host/app/modetest/enum.h:393: error: expected `;'
before "inline"
/home/yates/modetest/host/app/modetest/enum.h: In member function
`std::_Ios_Iost ate KEA::_EnumSuper <_enumType, EnumSub,
N>::get_stream( std::basic_istr eam<_CharT2, _Traits2>&)':
/home/yates/modetest/host/app/modetest/enum.h:761: error: expected
primary-expression before "const"
/home/yates/modetest/host/app/modetest/enum.h:761: error: expected `;'
before "const"
/home/yates/modetest/host/app/modetest/enum.h:768: error:
`start_position ' undeclared (first use this function)
/home/yates/modetest/host/app/modetest/enum.h: At global scope:
/home/yates/modetest/host/app/modetest/enum.h:789: error: expected
constructor, destructor, or type conversion before "_EnumSuper "
/home/yates/modetest/host/app/modetest/enum.h:789: error: expected `;'
before "_EnumSuper "
/home/yates/modetest/host/app/modetest/enum.h:805: error: expected
init-declarator before '&' token
/home/yates/modetest/host/app/modetest/enum.h:805: error: expected `;'
before '&' token
make: *** [/home/yates/modetest/host/app/modetest/nativelinux/enumpp.o]
Error 1
Compilation exited abnormally with code 2 at Fri Jan 6 11:41:16
PSS: I've also downloaded and installed boost.
--RY
More specificaly, here's what I got in trying to compile.
By the way, I have already downloaded and installed
boost. This is for gcc under fc3.
--RY
#include "enum.h"
int main(int argc, char **argv)
{
return 0;
}
cd /home/yates/modetest/host/app/modetest/
make -f enumpp.mak TARGET=native PLATFORM=linux
DSPROOT_DIR=/home/yates/modetest/ ATSIGN=
enumpp.mak:101: no file name for `include'
Building Component (enumpp) for Application enumpp
In file included from
/home/yates/modetest/host/app/modetest/enum.h:202,
from
/home/yates/modetest/host/app/modetest/enumpp.cpp:1:
/home/yates/modetest/host/app/modetest/StreamUDT.h: In function
`std::basic_ost ream<_CharT, _Traits>&
KEA::stream_ins erter(std::basi c_ostream<_Char T, _Traits>&, const
UDT&)':
/home/yates/modetest/host/app/modetest/StreamUDT.h:96: error: expected
`;' before "prepost"
/home/yates/modetest/host/app/modetest/StreamUDT.h:97: error: `prepost'
undeclared (first use this function)
/home/yates/modetest/host/app/modetest/StreamUDT.h:97: error: (Each
undeclared identifier is reported only once for each function it
appears in.)
/home/yates/modetest/host/app/modetest/StreamUDT.h: In function
`std::basic_ist ream<_CharT, _Traits>&
KEA::stream_ext ractor(std::bas ic_istream<_Cha rT, _Traits>&, UDT&)':
/home/yates/modetest/host/app/modetest/StreamUDT.h:151 : error: expected
`;' before "prepost"
/home/yates/modetest/host/app/modetest/StreamUDT.h:152 : error:
`prepost' undeclared (first use this function)
In file included from
/home/yates/modetest/host/app/modetest/enumpp.cpp:1:
/home/yates/modetest/host/app/modetest/enum.h: At global scope:
/home/yates/modetest/host/app/modetest/enum.h:257: error: ISO C++
forbids declaration of `value_type' with no type
/home/yates/modetest/host/app/modetest/enum.h:257: error:
`::value_type' is not a valid declarator
/home/yates/modetest/host/app/modetest/enum.h:257: error: expected `;'
before "value_type "
/home/yates/modetest/host/app/modetest/enum.h:264: error: ISO C++
forbids declaration of `result_type' with no type
/home/yates/modetest/host/app/modetest/enum.h:264: error: expected `;'
before "operator"
/home/yates/modetest/host/app/modetest/enum.h:334: error: expected `;'
before '}' token
/home/yates/modetest/host/app/modetest/enum.h:338: error: ISO C++
forbids declaration of `result_type' with no type
/home/yates/modetest/host/app/modetest/enum.h:338: error: expected `;'
before "operator"
/home/yates/modetest/host/app/modetest/enum.h:344: error: expected `;'
before '}' token
/home/yates/modetest/host/app/modetest/enum.h:387: error: ISO C++
forbids declaration of `size_type' with no type
/home/yates/modetest/host/app/modetest/enum.h:387: error: `::size_type'
is not a valid declarator
/home/yates/modetest/host/app/modetest/enum.h:387: error: expected `;'
before "max_length "
/home/yates/modetest/host/app/modetest/enum.h:393: error: expected `;'
before "inline"
/home/yates/modetest/host/app/modetest/enum.h: In member function
`std::_Ios_Iost ate KEA::_EnumSuper <_enumType, EnumSub,
N>::get_stream( std::basic_istr eam<_CharT2, _Traits2>&)':
/home/yates/modetest/host/app/modetest/enum.h:761: error: expected
primary-expression before "const"
/home/yates/modetest/host/app/modetest/enum.h:761: error: expected `;'
before "const"
/home/yates/modetest/host/app/modetest/enum.h:768: error:
`start_position ' undeclared (first use this function)
/home/yates/modetest/host/app/modetest/enum.h: At global scope:
/home/yates/modetest/host/app/modetest/enum.h:789: error: expected
constructor, destructor, or type conversion before "_EnumSuper "
/home/yates/modetest/host/app/modetest/enum.h:789: error: expected `;'
before "_EnumSuper "
/home/yates/modetest/host/app/modetest/enum.h:805: error: expected
init-declarator before '&' token
/home/yates/modetest/host/app/modetest/enum.h:805: error: expected `;'
before '&' token
make: *** [/home/yates/modetest/host/app/modetest/nativelinux/enumpp.o]
Error 1
Compilation exited abnormally with code 2 at Fri Jan 6 11:41:16
Randy wrote: Hi,
Can anyone point me to a complete, compilable example of Besser's ENUM++ mechanism? I downloaded it from CUJ and gave it a try but got errors just trying to compile the header enum.h.
--Randy Yates
Can you give me a link to the code you downloaded?
Cheers! --M
Randy wrote: Hi,
Can anyone point me to a complete, compilable example of Besser's ENUM++ mechanism? I downloaded it from CUJ and gave it a try but got errors just trying to compile the header enum.h.
--Randy Yates
I found the code here: ftp://ftp.cuj.com/pub/2003/cujjun2003.zip
The problem is that it appears Mr. Besser used an old (pre-C++03)
compiler. The problems can be fixed by adding the "typename" keyword at
various points (see http://womble.decadentplace.org.uk/c...disambiguation)
and adding a few typedefs to obviate the type of problem discussed in
this FAQ: http://www.parashift.com/c++-faq-lit...html#faq-35.18
For each of the two headers enum.h and StreamUDT.h, search for
"StringType ::" and add "typename " before it like this:
typedef typename StringType::val ue_type value_type;
Do likewise for other types that are nested within template classes,
e.g.:
const typename std::basic_istr eam<charT, Traits>::pos_ty pe
start_position= is.tellg();
and
typename _EnumSuper<_enu mType, EnumSub, N>::StringType
Where a struct/class inherits from std::unary_func tion or
std::binary_fun ction, add some typedefs in accord with the
aforementioned FAQ, e.g.:
struct Format: public std::unary_func tion<const char [], StringType>
{
typedef typename std::unary_func tion<const char [],
StringType>::re sult_type result_type;
typedef typename std::unary_func tion<const char [],
StringType>::ar gument_type argument_type;
// ...
};
and
struct StringLengthGre ater
: public std::binary_fun ction<const StringType*, const StringType*,
bool>
{
typedef typename std::binary_fun ction<const char [],
StringType>::re sult_type result_type;
typedef typename std::binary_fun ction<const char [],
StringType>::fi rst_argument_ty pe first_argument_ type;
typedef typename std::binary_fun ction<const char [],
StringType>::se cond_argument_t ype second_argument _type;
// ...
};
Then all the errors go away.
Cheers! --M
On 6 Jan 2006 11:25:41 -0800, "Randy" <ya***@ieee.org > wrote: Can anyone point me to a complete, compilable example of Besser's ENUM++ mechanism? I downloaded it from CUJ and gave it a try but got errors just trying to compile the header enum.h.
IMO, an "enum enhancement" that claims to be "easy to use" but "relies
on having the Boost preprocessor library [1] installed" isn't worth
the trouble.
It's also a good example of why CUJ has been 'discontinued'.
Best wishes,
Roland Pibinger
Hi M,
I still need some hand-holding as this is still not working
and it's beyond my C++ ability to find out why.
I made the changes you directed (I think) and am able
to compile error- and warning-free. The files are available
at www.digitalsignallabs.com/enumpp.cpp www.digitalsignallabs.com/enum.h www.digitalsignallabs.com/StreamUDT.h
If, however, I add an enumeration declaration as Besser
shows in his article:
#include "enum.h"
int main(int argc, char **argv)
{
ENUM3(IdiotResp onse, Yup, Nope, IDunno);
return 0;
}
I get errors:
g++ -c `cyg2dos /home/yates/modetest/host/app/modetest/enumpp.cpp`
-O3 -Wall -pthread -g -I /home/yates/modetest/host/inc/ -I
/home/yates/modetest/dsp/inc/ -DTARGET_NATIVE -DPLATFORM_LINUX -o
/home/yates/modetest/host/app/modetest/nativelinux/enumpp.o
/home/yates/modetest/host/app/modetest/enumpp.cpp:5:1: macro
"ENUM_GLOBAL_VA LUES" passed 4 arguments, but takes just 2
/home/yates/modetest/host/app/modetest/enumpp.cpp: In function `int
main(int, char**)':
/home/yates/modetest/host/app/modetest/enumpp.cpp:5: error:
`ENUM_GLOBAL_VA LUES' undeclared (first use this function)
/home/yates/modetest/host/app/modetest/enumpp.cpp:5: error: (Each
undeclared identifier is reported only once for each function it
appears in.)
/home/yates/modetest/host/app/modetest/enumpp.cpp:5: error: expected
`;' before "class"
Please help some more!
--Randy
Randy wrote: Hi M,
I still need some hand-holding as this is still not working and it's beyond my C++ ability to find out why.
I made the changes you directed (I think) and am able to compile error- and warning-free. The files are available at
www.digitalsignallabs.com/enumpp.cpp www.digitalsignallabs.com/enum.h www.digitalsignallabs.com/StreamUDT.h
Those look good.
If, however, I add an enumeration declaration as Besser shows in his article:
#include "enum.h"
int main(int argc, char **argv) { ENUM3(IdiotResp onse, Yup, Nope, IDunno);
return 0; }
I get errors:
g++ -c `cyg2dos /home/yates/modetest/host/app/modetest/enumpp.cpp` -O3 -Wall -pthread -g -I /home/yates/modetest/host/inc/ -I /home/yates/modetest/dsp/inc/ -DTARGET_NATIVE -DPLATFORM_LINUX -o /home/yates/modetest/host/app/modetest/nativelinux/enumpp.o /home/yates/modetest/host/app/modetest/enumpp.cpp:5:1: macro "ENUM_GLOBAL_VA LUES" passed 4 arguments, but takes just 2 /home/yates/modetest/host/app/modetest/enumpp.cpp: In function `int main(int, char**)': /home/yates/modetest/host/app/modetest/enumpp.cpp:5: error: `ENUM_GLOBAL_VA LUES' undeclared (first use this function) /home/yates/modetest/host/app/modetest/enumpp.cpp:5: error: (Each undeclared identifier is reported only once for each function it appears in.) /home/yates/modetest/host/app/modetest/enumpp.cpp:5: error: expected `;' before "class"
Please help some more!
--Randy
You might need to take the ENUM3 declaration outside of the function
body to give it external linkage. If I do that, the example works fine
with VC++6, which is the compiler the author used.
I did a somewhat cursory look at things on g++ 3.4.4, on which your
code doesn't work for me either, but I didn't see anything obviously
wrong. To reduce the noise, you can see the preprocessor error alone by
using the -E option, which yields:
macro "ENUM_GLOBAL_VA LUES" passed 4 arguments, but takes just 2
The ultimate problem seems to be with the use of this macro:
#define ENUM_LIST(size, tuple) \
BOOST_PP_LIST_E NUM(BOOST_PP_TU PLE_TO_LIST(siz e, tuple))
I'm no Boost PP expert, and so I'll have to recommend that you take
this to the Boost User list at http://lists.boost.org/mailman/listinfo.cgi/boost-users or perhaps to a
GNU forum. I didn't see anything about a compiler incompatibility on
Boost's website (indeed, http://engineering.meta-comm.com/boo...processor.html
seems to indicate that it should be fully functional), so I'd talk to
the folks in the know.
I also briefly tried tracking down the author of the article to no
avail. You might be able to find him out there somewhere, and ask him
for help directly.
Sorry I can't be more help.
Cheers! --M
mlimber wrote: using the -E option, which yields:
macro "ENUM_GLOBAL_VA LUES" passed 4 arguments, but takes just 2
The ultimate problem seems to be with the use of this macro:
#define ENUM_LIST(size, tuple) \ BOOST_PP_LIST_E NUM(BOOST_PP_TU PLE_TO_LIST(siz e, tuple))
I'm no Boost PP expert, and so I'll have to recommend that you take this to the Boost User list at http://lists.boost.org/mailman/listinfo.cgi/boost-users or perhaps to a GNU forum. I didn't see anything about a compiler incompatibility on Boost's website (indeed, http://engineering.meta-comm.com/boo...processor.html seems to indicate that it should be fully functional), so I'd talk to the folks in the know.
I also briefly tried tracking down the author of the article to no avail. You might be able to find him out there somewhere, and ask him for help directly.
Sorry I can't be more help.
The quick dirty fix for your preprocessing error... First, include
<boost/preprocessor/tuple/rem.hpp> with the rest of the Boost.Preproces sor
includes. Then alter line 830 (in the definition of BEGIN_ENUM) from...
ENUM_GLOBAL_VAL UES(type, value_list) \
....to...
ENUM_GLOBAL_VAL UES(type, BOOST_PP_TUPLE_ REM(N)(value_li st)) \
Regards,
Paul Mensonides This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: AngleWyrm |
last post by:
"The C++ Programming Language" by Bjarne Stroustrup, copyright 1997 by AT&T,
section 4.8 (pp 77):
"A value of integral type may be explicitly converted to an enumeration
type. The result of such a conversion is undefined unless the value is
within the range of the enumeration. For example:
enum flag { x=1, y=2, z=4, e=8 }; // range 0:15
flag f1 = 5; // type error: 5 is not of type flag
flag f2 = flag(5); // ok: flag(5) is of type flag and...
|
by: Klaus Schneider |
last post by:
Hi all!
I'm having trouble with a template function with variable arguments when I
parse an enum type as variable argument. Example:
template <class T>
bool test(int num, ...)
{
va_list ap;
int ind;
|
by: Nebula |
last post by:
Consider
enum Side {Back,Front,Top,Bottom};
enum Side a;
Now, why is
a = 124;
legal (well it really is an integer, but still,
checking could be performed..) ?
Wouldn't enums be more useful if there was a
bit more typechecking ?
|
by: Andreas Huber |
last post by:
Hi there
Spending half an hour searching through the archive I haven't found a
rationale for the following behavior.
using System;
// note the missing Flags attribute
enum Color
{
|
by: Visual Systems AB \(Martin Arvidsson\) |
last post by:
Hi!
I have created an enum list like this:
enum myEnum : int
{
This = 2,
That,
NewVal = 10,
LastItm
| |
by: Randy |
last post by:
Hi,
I downloaded and tried the ENUM++ code from CUJ
http://www.cuj.com/documents/s=8470/cujboost0306besser/
but can't even get it to compile (see following). I
have also downloaded and installed the boost library.
This is using gcc under FC3.
|
by: kar1107 |
last post by:
Hi all,
Can the compiler chose the type of an enum to be signed or unsigned
int? I thought it must be int; looks like it changes based on the
assigned values. Below if I don't initialize FOO_STORE to be, say -10,
I get a warning about unsigned comparison and I'm seeing an infinite
loop.
If I do initialize FOO_STORE = -10, I don't see any warnings. No
infinite loop.
|
by: Steven Nagy |
last post by:
So I was needing some extra power from my enums and implemented the
typesafe enum pattern.
And it got me to thinking... why should I EVER use standard enums?
There's now a nice little code snippet that I wrote today that gives me
an instant implementation of the pattern. I could easily just always
use such an implementation instead of a standard enum, so I wanted to
know what you experts all thought.
Is there a case for standard enums?
|
by: jacob navia |
last post by:
Hi
We are rewriting the libc for the 64 bit version of lcc-win
and we have added a new field in the FILE structure:
char *FileName;
fopen() will save the file name and an accessor function
will return the file name given a FILE *.
Questions:
What would be the best name for this function?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |