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

Pages: 1-

C question

Name: Anonymous 2010-07-01 21:10

To make things clearer for myself as I learn C, I do casts like this:

#define cast(x) (x)
cast(unsigned int)time(NULL);

Is it considered bad style or anything?

Name: Anonymous 2010-07-01 21:22

int main cast(void) { puts cast("lol what"); }

Name: Anonymous 2010-07-01 21:24

>>2
cast(cast(cast(int) cast(main)  cast(void) cast({puts cast("lol what");)))

Name: Anonymous 2010-07-01 21:28

#define cast(type, value) ((type)(value))

Name: Anonymous 2010-07-01 22:06

Just use the conventions. I hate having to look at code that looks like an entirely different language because the programmer thought it would be cute to abuse macros.

Name: Anonymous 2010-07-01 22:06

>>1
No, not at all. As everyone knows, C is a very boring language. That's why other programmers will appreciate it if you use preprocessor tricks to make up your own variants, with new ways to write the same old boring operations.
In fact, with a little cleverness you can radically alter the feel of the language without introducing too many small inconsistencies and gotchas. Remember; every new project is a blank slate, so just be creative and experiment!

Name: Anonymous 2010-07-01 22:16

>>1
Well, that's how you cast things in D. Oddly if you try using a C-style cast it recognizes it and complains.

Name: Anonymous 2010-07-01 22:37

Name: Anonymous 2010-07-01 22:38

>>4

Name: Anonymous 2010-07-01 22:49

>>8
wat

Name: Anonymous 2010-07-01 23:05

>>8
Yes, faggots like those.

Name: Anonymous 2010-07-02 1:23

>>8
I suddenly feel irate. I think I'll just start writing C like that to take it out on code maintainers.

Name: Anonymous 2010-07-02 1:46

OP should switch to sepples just so he can enjoy static_cast, dynamic_cast and reinterpret_cast.

Name: Anonymous 2010-07-02 1:49

Or compile C code with g++.

Name: Anonymous 2010-07-02 2:30

>>8
it hurts the brain. sunifdef+indent could clean that up easily though.

Name: Anonymous 2010-07-02 9:57

cast(MY ANUS)

Name: Anonymous 2010-07-02 10:05

>>13
Just switch to D directly and save more of your sanity.
>>8
gcc was a pascal compiler before C.

Name: Anonymous 2010-07-02 10:18

#define comment(...) /* __VA_ARGS__ */

Name: Anonymous 2010-07-02 10:26

>>13
//spells.h, a void.h alternative for C++
#define rast reinterpret_cast
#define dast dynamic_cast
#define sast static_cast

Name: Anonymous 2010-07-02 18:18

>>18
/* Comments */ are removed before macros are expanded. #define comment(...) alone would have the same effect.

Name: Anonymous 2010-07-02 18:31

>>20
just like how >>1 could have just done #define cast...

Name: Anonymous 2010-07-02 19:01

>>21
No, he couldn't.

Name: Anonymous 2010-07-02 22:45

>>22
Yes he could. You're a fucking idiot.

Name: Anonymous 2010-07-02 23:24

>>23
You seem mad old chap.

Name: Anonymous 2010-07-02 23:57

>>24
I'm not. I simply call it like it is.

Name: Anonymous 2010-07-03 2:28

I've seen something like this in StarCon2 code(well, open source clone of it)


#define GLOBAL(var) g_##var

int readSICP()
{
   GLOBAL(i_read_sicp_today) = 1;
}

Name: Anonymous 2010-07-03 4:50


typedef unsigned int DWORD
typedef void* HANDLE

Name: Anonymous 2011-02-04 12:46


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