IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 2 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Determining platform type/OS in gcc via #defines
Is there a .h to include, or some sort of built-in #define that I can use to determine chip type and OS in gcc?
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Maybe Mozilla source would help...
Or maybe not. There's a web page with browsable code, and a CPU routine [link|http://lxr.mozilla.org/seamonkey/source/gc/boehm/os_dep.c|here].

It's pretty messy and is likely far more elaborate than you need... Going up the tree to .../boehm/ gives the other files in the build.

Good luck.

Cheers,
Scott.
New Yes, this is the sort of thing I was looking for:
[link|http://lxr.mozilla.org/seamonkey/source/gc/boehm/gcconfig.h#27|http://lxr.mozilla.o...ehm/gcconfig.h#27]

Thanks. I'll try it out tomorrow at work.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Is this on Linux?
Make system do a uname -a.
-drl
New what he said
will work for cash and other incentives [link|http://home.tampabay.rr.com/boxley/resume/Resume.html|skill set]

You think that you can trust the government to look after your rights? ask an Indian
New I wasn't clear enough.
I need this to happen at compile time. Currently, the build system generates -D entries based on things like uname. I would like to determine OS/platform (endian stuff, really, but I can get that from endian.h on unix platforms) based on built-in #defines produced by the compiler or present in system .h files. I don't want to have to detect the OS in the build system.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Gotta be a #pragma right?
You basically tell the compiler "do this if this is the environment..."
-drl
New #define
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New /usr/include/machine/cpu.h (like that?)
will work for cash and other incentives [link|http://home.tampabay.rr.com/boxley/resume/Resume.html|skill set]

You think that you can trust the government to look after your rights? ask an Indian
New Doesn't exist on this box.
Or were you just giving an example of what you thought I was looking for?
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New osx has 3 entries
/usr/include/machine/cpu.h
* @APPLE_LICENSE_HEADER_END@
*/

#ifndef _BSD_MACHINE_CPU_H_
#define _BSD_MACHINE_CPU_H_


#if defined (__ppc__)
#include "ppc/cpu.h"
#elif defined (__i386__)
#include "i386/cpu.h"
#else
#error architecture not supported
#endif
#endif /* _BSD_MACHINE_CPU_H_ */


as you can see it is a stub so you might be able to write one out and add it to the build.
/usr/include/i386/cpu.h
* @APPLE_LICENSE_HEADER_END@
*/
/*
* HISTORY
*
*/

#ifndef _BSD_I386_CPU_H_
#define _BSD_I386_CPU_H_

#include <sys/appleapiopts.h>

#ifdef __APPLE_API_OBSOLETE
#define cpu_number() (0)
#endif /* __APPLE_API_OBSOLETE */

#endif /* _BSD_I386_CPU_H_ */

hope anything helps, you might want to write one
thanx,
bill
will work for cash and other incentives [link|http://home.tampabay.rr.com/boxley/resume/Resume.html|skill set]

You think that you can trust the government to look after your rights? ask an Indian
New Heh. No /usr/include/i386 either.
But yes, that's the sort of thing I'm looking for. Thanks.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New I don't really have an answer handy...
...but the question is whether you want that information at compile time or at run time?
New Compile time, without passing -D switches.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New If memory serves me correct...
...those -D switches are really just macro constants in disguise. So you should be able to use the constants in conditional compilation tests.
New Right. But I don't want to pass -D switches. :-)
That's what I'm doing now; ie. on Linux I add -D_LINUX to the gcc command line, and look for #ifdef _LINUX in the code. I'm looking for a predefined macro constant so I don't have to pass the -D switches any more.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Could autoconf help?
I've seen lot of programs do build-type checks in autoconf.

Wade.

Microsoft are clearly boiling the frogs.

New We have our own build system; autoconf not a part of it
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Autoconf could still be useful
The way it works is that it runs a bunch of tests to figure out what the environment is. Even if you have your own system, you could download autoconf and steal the tricks they are using.
New Autoconf does so at runtime.
ie. through uname, etc.

Which isn't particularly useful during compile time. :-)
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Are we talking about "configure" script?
As used by scores of Open Source apps? It works _before_ compile time.
--

We have only 2 things to worry about: That
things will never get back to normal, and that they already have.
New You misunderstand me.
The techniques that configure/autoconf use are runtime techniques, and hence useless to my goal of doing the configuration at compile time. :-)

Basically, I ended up using stuff like:

\n#if defined(MSC_VER)\n// windows stuff\n#elif defined(linux) || defined(__linux__)\n// linux stuff\n#elif defined(sun) || defined(__sun__)\n// solaris stuff\n#else\n#error Unknown or unsupported OS\n#endif\n
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New One man's compile time...
...is another man's run time. How about having the make file run a configuration procedure that generates a header file with the constants in it. Something with pipes or grep or awk or.... :-)
New I already do that; I don't want to. :-)
Or at least, something similar. I want the entire detection to happen in the source code, not as the result of something that runs before the compile.

Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New So what you're really wanting is...
...to know if the compiler itself is autodetecting the environment and whether that detection is available in the conditional compilation?
New s/wanting/using
Here's what I came up with, which seems to work fine:

[link|http://z.iwethey.org/forums/render/content/show?contentid=73714|http://z.iwethey.org...w?contentid=73714]
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
     Determining platform type/OS in gcc via #defines - (admin) - (25)
         Maybe Mozilla source would help... - (Another Scott) - (1)
             Yes, this is the sort of thing I was looking for: - (admin)
         Is this on Linux? - (deSitter) - (8)
             what he said -NT - (boxley)
             I wasn't clear enough. - (admin) - (6)
                 Gotta be a #pragma right? - (deSitter) - (1)
                     #define -NT - (admin)
                 /usr/include/machine/cpu.h (like that?) -NT - (boxley) - (3)
                     Doesn't exist on this box. - (admin) - (2)
                         osx has 3 entries - (boxley) - (1)
                             Heh. No /usr/include/i386 either. - (admin)
         I don't really have an answer handy... - (ChrisR) - (13)
             Compile time, without passing -D switches. -NT - (admin) - (12)
                 If memory serves me correct... - (ChrisR) - (11)
                     Right. But I don't want to pass -D switches. :-) - (admin) - (10)
                         Could autoconf help? - (static) - (9)
                             We have our own build system; autoconf not a part of it -NT - (admin) - (8)
                                 Autoconf could still be useful - (neelk) - (7)
                                     Autoconf does so at runtime. - (admin) - (6)
                                         Are we talking about "configure" script? - (Arkadiy) - (5)
                                             You misunderstand me. - (admin) - (4)
                                                 One man's compile time... - (ChrisR) - (3)
                                                     I already do that; I don't want to. :-) - (admin) - (2)
                                                         So what you're really wanting is... - (ChrisR) - (1)
                                                             s/wanting/using - (admin)

Would you like some Chocolate Foam with that Mercedes, sir?
105 ms