From owner-freebsd-questions Fri Apr 13 7:23:58 2001 Delivered-To: freebsd-questions@freebsd.org Received: from xena.gsicomp.on.ca (cr677933-a.ktchnr1.on.wave.home.com [24.43.230.149]) by hub.freebsd.org (Postfix) with ESMTP id 45D5737B424 for ; Fri, 13 Apr 2001 07:23:54 -0700 (PDT) (envelope-from matt@gsicomp.on.ca) Received: from hermes (hermes.gsicomp.on.ca [192.168.0.18]) by xena.gsicomp.on.ca (8.11.1/8.11.3) with SMTP id f3DELdp01487; Fri, 13 Apr 2001 10:21:39 -0400 (EDT) (envelope-from matt@gsicomp.on.ca) Message-ID: <010e01c0c424$9923a250$1200a8c0@gsicomp.on.ca> From: "Matthew Emmerton" To: "Ying-Chieh Liao" Cc: References: <20010413015404.A30645@terry.dragon2.net> <20010412173833.B7929@billygoat.slb.to> Subject: Re: OT: cast int to enum in C++ Date: Fri, 13 Apr 2001 10:18:22 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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