Sponsored Content
Top Forums Programming C- trying to code a 'spare array'; 'enum' fauled. Post 302697989 by Corona688 on Friday 7th of September 2012 05:24:54 PM
Old 09-07-2012
Quote:
Originally Posted by alex_5161
(It is not just #define that vaiporing on precompilation. )
Unfortunately I must disagree. For your purposes, they amount to #define's without the mess. They don't vanish in precompilation, but they do vanish in a later phase of compilation, values set and irreversible. Your program can't iterate through them, convert them to or from strings, or map one set of them to another unless you do it the hard way, building your own tables of values to look them up in. They're just labels for numbers.

In C++, enum's are a little more strict to prevent some of that weirdness. They didn't add anything that'd actually help you, though. They didn't add any syntax to iterate through them, convert them to or from strings, or map one set of them to another, just made it harder to set an enum to an invalid value. They prevented you from doing arithmetic on enums like myenum++ since that might possibly end up at an invalid enum. They prevented you from assigning an enum from an integer without a typecast in case that causes an invalid enum. And so forth. (No, it doesn't actually check if the enums are valid if you typecast. It just lets it through.) So C++ code at runtime is still as ignorant of their status as anything but numbers as C is.

Last edited by Corona688; 09-07-2012 at 06:40 PM..
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Vfstab on spare disk - HOW ? Mount ?

Hi, guys ! Could someone clarify one thing for me: I start machine from disk0, and want to check the /etc/vfstab on disk1. How do i do it ? Tried to write: cd / mount /dev/dsk/c0t1d0s0 /mnt But if I do cd /mnt, it is empty. I expected to see disk1 there ? Or am I wrong ? How do I... (3 Replies)
Discussion started by: DGoubine
3 Replies

2. Programming

what is the base type of enum

helo i have asked in exam what that what is the base type of enum options are given bewlo (1) long int (2) short int (3) signed int (4) unsigned int can u tell me what is the exact answer from the above option Regards, Amit (1 Reply)
Discussion started by: amitpansuria
1 Replies

3. IP Networking

DNS ENUM RR interpretation

Hi Guys, This is really really urgent. Am looking out for some quick answers. I'm developing a DNS Resolver client that interprets DNS Query repsonses & pass on the needful to DNS applications. When an ENUM query(modified to an nslookup naptr query) is issued & an NAPTR RR(Resource Record)... (1 Reply)
Discussion started by: smanu
1 Replies

4. Programming

enum in c++

#include <iostream> #include <stdio.h> using namespace std; typedef struct A { enum a{ red,blue,green}a; }obj11; obj11 obj1; int main() { //obj1.a=red; // how to set variable ? cout<<"sizeof struct is n"<<sizeof(obj1); cout<<"obj1.a is"<<obj1.a; if... (1 Reply)
Discussion started by: crackthehit007
1 Replies

5. Solaris

Hot Spare pool

One more query in SVM :) Now with hot spare spool... I can understand adding/replacing a slice in particular hot spare pool with "-a / -r" option (or) adding a slice to all existing hot spare pool with "-all" option. Here my query is for deleting, we have only option "-d". 1) If the hot... (2 Replies)
Discussion started by: gowthamakanthan
2 Replies

6. Solaris

Hot Spare replacement

Hi Guys, Can Someone pls let me know the thorough process for Hot spare replacement as current Hot spare slice has broken down . :mad: Thanks ---------- Post updated at 06:34 PM ---------- Previous update was at 05:21 PM ---------- Update : Its a solaris 10 box (1 Reply)
Discussion started by: Solarister
1 Replies

7. Programming

enum and C preprocessor

Say I have a list of enumerations I wish to use to select a variable at compile-time: enum pins { PIN_A=1, PIN_B=7, PIN_C=6, } int VAR1, VAR2, VAR3, VAR4, VAR5, VAR6, VAR7; #define PIN_TO_VAR(NUM) VAR ## NUM int main(void) { PIN_TO_VAR(PIN_A)=32;... (2 Replies)
Discussion started by: Corona688
2 Replies

8. Solaris

How to get spare disks working

Dears how can i make this spare disks working online to replace a defective disks vxdisk list DEVICE TYPE DISK GROUP STATUS c0t10d0s2 sliced - - error c0t11d0s2 sliced disk08 rootdg online c1t16d0s2 sliced ... (3 Replies)
Discussion started by: thecobra151
3 Replies

9. Programming

Mixed enum types - coverity defect

Hi All, I came across this error "MIXING ENUM TYPES" when I run my C program against the Coverity Tool. I've made many search relating to the error, but I didnt find the exact solution. Can anyone help me to overcome this.? Thanks in Advance.!! (3 Replies)
Discussion started by: Parameswaran
3 Replies

10. Solaris

How to determine if i have spare disks in Solaris?

Hi Guys, obviously new to SOLARIS SUN SPARC 5.10 I would really appreciate if you help me see how to find free disks available in my system. Like i am a linux admin. If i want to grow a file system in linux. I would first have a look at my volume groups to see if they have free PEs if not then... (2 Replies)
Discussion started by: aiqbal
2 Replies
glu(3erl)						     Erlang Module Definition							 glu(3erl)

NAME
glu - A part of the standard OpenGL Utility api. DESCRIPTION
A part of the standard OpenGL Utility api. See www.opengl.org Booleans are represented by integers 0 and 1. DATA TYPES
clamp() : A float clamped between 0.0 - 1.0 enum() : An integer defined in gl.hrl mem() : memory block offset() : An integer which is an offset in an array EXPORTS
tesselate(X1::Vec3, Vs::[Vec3]) -> {Triangles, VertexPos} Types Vec3 = {float(), float(), float()} Triangles = [VertexIndex::integer()] VertexPos = binary() General purpose polygon triangulation. The first argument is the normal and the second a list of vertex positions. Returned is a list of indecies of the vertices and a binary (64bit native float) containing an array of vertex positions, it starts with the ver- tices in Vs and may contain newly created vertices in the end. build1DMipmapLevels(Target::enum(), InternalFormat::integer(), Width::integer(), Format::enum(), Type::enum(), Level::integer(), Base::integer(), Max::integer(), Data::binary()) -> integer() See external documentation. build1DMipmaps(Target::enum(), InternalFormat::integer(), Width::integer(), Format::enum(), Type::enum(), Data::binary()) -> integer() See external documentation. build2DMipmapLevels(Target::enum(), InternalFormat::integer(), Width::integer(), Height::integer(), Format::enum(), Type::enum(), Level::integer(), Base::integer(), Max::integer(), Data::binary()) -> integer() See external documentation. build2DMipmaps(Target::enum(), InternalFormat::integer(), Width::integer(), Height::integer(), Format::enum(), Type::enum(), Data::binary()) -> integer() See external documentation. build3DMipmapLevels(Target::enum(), InternalFormat::integer(), Width::integer(), Height::integer(), Depth::integer(), Format::enum(), Type::enum(), Level::integer(), Base::integer(), Max::integer(), Data::binary()) -> integer() See external documentation. build3DMipmaps(Target::enum(), InternalFormat::integer(), Width::integer(), Height::integer(), Depth::integer(), Format::enum(), Type::enum(), Data::binary()) -> integer() See external documentation. checkExtension(ExtName::string(), ExtString::string()) -> 0 | 1 See external documentation. cylinder(Quad::integer(), Base::float(), Top::float(), Height::float(), Slices::integer(), Stacks::integer()) -> ok See external documentation. deleteQuadric(Quad::integer()) -> ok See external documentation. disk(Quad::integer(), Inner::float(), Outer::float(), Slices::integer(), Loops::integer()) -> ok See external documentation. errorString(Error::enum()) -> string() See external documentation. getString(Name::enum()) -> string() See external documentation. lookAt(EyeX::float(), EyeY::float(), EyeZ::float(), CenterX::float(), CenterY::float(), CenterZ::float(), UpX::float(), UpY::float(), UpZ::float()) -> ok See external documentation. newQuadric() -> integer() See external documentation. ortho2D(Left::float(), Right::float(), Bottom::float(), Top::float()) -> ok See external documentation. partialDisk(Quad::integer(), Inner::float(), Outer::float(), Slices::integer(), Loops::integer(), Start::float(), Sweep::float()) -> ok See external documentation. perspective(Fovy::float(), Aspect::float(), ZNear::float(), ZFar::float()) -> ok See external documentation. pickMatrix(X::float(), Y::float(), DelX::float(), DelY::float(), Viewport::{integer(), integer(), integer(), integer()}) -> ok See external documentation. project(ObjX::float(), ObjY::float(), ObjZ::float(), Model::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, Proj::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, View::{integer(), integer(), integer(), inte- ger()}) -> {integer(), WinX::float(), WinY::float(), WinZ::float()} See external documentation. quadricDrawStyle(Quad::integer(), Draw::enum()) -> ok See external documentation. quadricNormals(Quad::integer(), Normal::enum()) -> ok See external documentation. quadricOrientation(Quad::integer(), Orientation::enum()) -> ok See external documentation. quadricTexture(Quad::integer(), Texture::0 | 1) -> ok See external documentation. scaleImage(Format::enum(), WIn::integer(), HIn::integer(), TypeIn::enum(), DataIn::binary(), WOut::integer(), HOut::integer(), Type- Out::enum(), DataOut::mem()) -> integer() See external documentation. sphere(Quad::integer(), Radius::float(), Slices::integer(), Stacks::integer()) -> ok See external documentation. unProject(WinX::float(), WinY::float(), WinZ::float(), Model::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, Proj::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, View::{integer(), integer(), integer(), inte- ger()}) -> {integer(), ObjX::float(), ObjY::float(), ObjZ::float()} See external documentation. unProject4(WinX::float(), WinY::float(), WinZ::float(), ClipW::float(), Model::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, Proj::{float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float(), float()}, View::{integer(), integer(), integer(), integer()}, NearVal::float(), FarVal::float()) -> {integer(), ObjX::float(), ObjY::float(), ObjZ::float(), ObjW::float()} See external documentation. AUTHORS
<> wxErlang 0.98.9 glu(3erl)
All times are GMT -4. The time now is 03:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy