Date: Fri, 13 Apr 2001 10:18:22 -0400 From: "Matthew Emmerton" <matt@gsicomp.on.ca> To: "Ying-Chieh Liao" <ijliao@csie.nctu.edu.tw> Cc: <freebsd-questions@FreeBSD.ORG> Subject: Re: OT: cast int to enum in C++ Message-ID: <010e01c0c424$9923a250$1200a8c0@gsicomp.on.ca> References: <20010413015404.A30645@terry.dragon2.net> <20010412173833.B7929@billygoat.slb.to>
next in thread | previous in thread | raw e-mail | index | archive | help
> Since your post is off-topic, please prefix the subject with "OT:". > > > In C, compiling following code is all ok but in C++, there's some > > err msgs : > > > > test.cpp:12: conversion from `int' to `enum test' > > > > I've tried g++ -fenum-int-equiv test.cpp, but it said that this flag > > is no longer supported :< what can I do ? dont suggest me to change > > tmp(1) to tmp(TEST1) ... Well, that's the right thing to do, or else cast your int argument to one of type 'test' -- tmp( (test) 1); I often find people using enum types just so they can give fancy names to integer values. Instead, it's probably just as easy to use #defines, which look the same, but only give type warnings if something's *really* wrong. (such as using a #define with a string argument where an integer is expected.) -- Matt Emmerton To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?010e01c0c424$9923a250$1200a8c0>