long long preprocessor

Basically I want to use the preprocessor to define LLONG as long long or whatever alternative there is. I've been googling it for a while now and have finally given up, any help is welcome.

Edit:Please do not mention stdint.h or limits.h I am trying to write a header that does NOT rely on these. Also I'd like a c89/c90 solution please.
Last edited on
closed account (Dy7SLyTq)
...
 
#define LLONG long long 


 
typedef LLONG long long
@DTSCode
typedef LLONG long long



typedef long long LLONG;
Last edited on
...(sigh) I thought that it was obvious that I knew how to do that, what I meant was something like this:
1
2
3
4
5
6
#ifdef LONG_LONG_TYPE
#define LLONG long long
#elif LONG_INT_TYPE
#define LLONG long int
etc
#endif 

But I having trouble finding out what to test for.
Last edited on
closed account (Dy7SLyTq)
@vlad: yeah sorry my mistake.
@op: it is not obvious. you wrote
I want to use the preprocessor to define LLONG as long long

i fail to see where you expect us to know that you want to do testing.
or whatever alternative there is
Edit: Besides do you really think I wouldn't have found something that simple via google?
Edit: If I seem rude I apologize, it's just the way I talk.
Last edited on
closed account (Dy7SLyTq)
@op: that still doesnt mean you wanted testing... and your not being clear in describing your problem. test for what?
Well I know that long long isn't always available but alternatives such as long int are usually available in that event and if there is absolutely no built in alternative then I'd like a struct to take it's place if possible.

Edit: Typo corrected
Last edited on
Well I know that long long is always available
If it's not in the standard, it isn't. That's the whole point of the standard. It's not defined in the original ANSI/ISO C as I recall.
uh yeah
is
was meant to be isn't, I since corrected that typo. Point is I'm sure I read somewhere that there was alternative types when long long is not available, if I'm wrong then please correct me.
Last edited on
OP is trying to do compiler-specific magic without using compiler-specific info.

Either use compiler's <stdint.h> / <cstdint>
or use <boost/stdint.hpp>

You can make yourself a macro to select between the two:

1
2
3
4
5
#ifdef INT64_C
  #define LLONG int64_t
#else
  #define LLONG int32_t
#endif 

Good luck!
Oh well, it was worth a shot, thanks anyways
I read somewhere that there was alternative types when long long is not available

Yes, 15+ years ago, before this practice was standardized by C99, different vendors had differently-named 64-bit types. Microsoft had __int64, many platforms used not-yet-standard int64_t/uint64_t, some just made unsigned long 64-bit.

I'd like a c89/c90 solution

Use gint64 from glib, or any other general-purpose C library that's old enough. It is counter-productive to do that work yourself.
Thanks, I'll take a look at the header, I just better make sure to credit them.
Ah well, I couldn't find anything new in their headers, just __int64 which I already knew about, any other suggestions? Even page that mentions compiler specific integers will be welcome.
Topic archived. No new replies allowed.