Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

constant

Name: Anonymous 2011-11-26 1:05

What is the proper way of defining constants?


1)#define fag 0
2)const int fag = 0;

Name: Anonymous 2011-11-26 1:09

Both.

Name: Anonymous 2011-11-26 1:13

[code]
#define const int #define
const fag 0
[code]

Name: Anonymous 2011-11-26 1:14

>>3
well now i fucked that one up

#define const #define
const fag 0

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-11-26 1:35

>>4
UnFortunately some compilers don't allow redefining #define/#include
I've found out that gcc doesn't like
#define d #define
and i have to type extra chars in void.h and similar headers(usually i have append a huge chunk of empty #define's if there is need)

Name: Anonymous 2011-11-26 1:59

>>5

if defined macro definitions could expand to other definitions of macro definitions, would that make the c preprocessor touring complete?

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-11-26 2:13

>>6
Only in compilers which support this, like DMC

Name: Anonymous 2011-11-26 4:07

Name: Anonymous 2011-11-26 4:47

>>8
Baby dissection.

Name: VIM FOR LIFE 2011-11-26 6:09

>>5
But why care about typing the extra few characters? I simply hit ^N like a baws using autocompletion.

Name: Anonymous 2011-11-26 6:44

>>9
Your powers of observation continue to serve you well.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-11-26 7:12

>>10
You don't have to use autocomplete if you just use one character for #define
auto-complete is not supported in notepad2, and i don't really need it as i prefer using #define's and typing shorter strings.
3-4 chars max should be ideal, but i don't mind typing a few extra.

Name: Anonymous 2011-11-26 11:29

>>1

const int have some disadvantages. First, you'll have to move the definition to a separate translation unit (if the constant is declared in a header file). Second, you can't use it in case labels.

The best way to group a set of related constants together is through an enum. If you want to declare a single constant, though, I'd go with a #define.

Name: Anonymous 2011-11-26 12:12

>>1
(define fag 0)

Name: Anonymous 2011-11-26 13:04

>>14
Fixed your lipth for you.

(define fag 1)

Name: sage 2011-11-26 13:25

>>15
Fixed your lipth for you.

(define fag 2)

Name: Anonymous 2011-11-26 13:56

>>16

Fixed your lipth for you.

(defconstant fag 'three)

Name: Anonymous 2011-11-26 14:02

The fag constant already provided by lisp interpreter, that code is superfluous.

Name: Anonymous 2011-11-26 16:36

If you type fag into any Lisp interpreter it replies with ``oh, be nice !''

Name: Anonymous 2011-11-26 18:20

>>8
Damn you.

Don't change these.
Name: Email:
Entire Thread Thread List