When writing an app that one wants to have compile on mac, linux and windows, what is the best way of managing the different libraries that will need to be included on the various operating systems. For example, using the glut opengl toolkit requires different includes on each operating system.
...
We have the following in our codebase, in a component file:
{$IFDEF ADO}
FDatabase : TADODatabase;
{$ELSE}
FDatabase : TODBCDatabase;
{$ENDIF}
The reason is that for various legacy applications, one or the other type of database connection and set of classes is to be used.
However, while configuring a new machine, it seems that our c...
In C++, is this:
#ifdef COND_A && COND_B
the same as:
#if defined(COND_A) && defined(COND_B)
?
I was thinking it wasn't, but I haven't been able to find a difference with my compiler (VS2005).
...
Hello,
I am trying to include 2 platform-specific stdafx.h files in my .cpp file, but the compiler is unhappy when I try to #ifdef it.
#ifdef _WIN32
#include "stdafx.h"
#elif _MAC
#include "MAC/stdafx.h"
#endif
You may wonder why I am using stdafx.h in the Mac code, but that is not important at the moment :).
When I try to compile...
Good Morning,
I have a unit which I want to use in two different programs, to tell the difference I wanted to Define a symbol and then check that in the unit.
In my DPR for the project I have;
program Project1;
{$Define MYDEF}
uses
Forms,
...
and in my Form1 file I have
procedure TForm1.FormCreate(Sender: TObject);
begin
{...
What C preprocessor conditional should I use for OS X specific code? I need to include a specific library if I am compiling for OS X or a different header if I am compiling for Linux.
I know there is __APPLE__ but I don't know if that is a current conditional for OS X 10.x.
...
I'm trying to streamline large chunk of legacy C code in which, even today, before doing the build guy who maintains it takes a source file(s) and manually modifies the following section before the compilation based on the various types of environment.
The example follows but here's the question. I'm rusty on my C but I do recall that ...
Hi all,
I doubt if there is a way to make compile-time conditions in Java like #ifdef #ifndef in C++.
My problem is that have an algorithm written in Java, and I have different running time improves to that algorithm. So I want to measure how much time I save when each improve is used.
Right now I have a set of boolean variables that a...
A programmer I respect said that in C code, #if and #ifdef should be avoided at all costs, except possibly in header files. Why would it be considered bad programming practice to use #ifdef in a .c file?
...
To follow from my previous question about virtual and multiple inheritance (in a cross platform scenario) - after reading some answers, it has occurred to me that I could simplify my model by keeping the server and client classes, and replacing the platform specific classes with #ifdefs (which is what I was going to do originally).
Will...
Linux has this nice function dprintf:
The functions dprintf() and vdprintf() (as found in the glibc2 library) are exact analogues of fprintf() and vfprintf(), except that they output to a file descriptor fd instead of to a given stream.
however as that same source points out:
These functions are GNU extensions, not in C or POS...
Hi all.. I searched for a long time on stackoverflow using every keyword I could think of to solve this. I am programming for iphone and I have a lite and paid version of my app. I followed the instructions here Creating Lite Versions of iPhone Games / Apps for duplicating the target. This works and now I am working on slimming down t...
I am using gfortran to compile FORTRAN 77 and would like to have DEBUG build options by using the preprocessor directive #ifdef. However, when I use them I get compile time warnings "Illegal preprocessor directive". Is it possible to have this functionality without deviating from the standard toolchain?
...
Hi, I would like to do something similar to #ifdef __linux__, but with the bada SDK. Is there a constant defined by default?
Also, can I detect when I am compiling for the simulator?
...
Hi,
I'm working with an old C code that still has a few dusty corners. I'm finding a lot of #ifdef statements around that refer to operating systems, architectures, etc. and alter the code for portability. I don't know how many of these statements are still relevant today.
I know that #ifdef isn't the best idea in certain circumstance...
I just tried
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
begin
{$IFDEF CONSOLE}
beep;
{$ENDIF}
end.
and expected to hear a beep during runtime, but not. The following test works, though:
if IsConsole then
beep;
Why doesn't the compile-time test work? As far as I can understand from this doc, it sure shoul...
Can someone please explain what #ifdef..#else..#endif does in this piece of code? It's from an open-source iphone twitter client.
#ifdef ENABLE_OAUTH
@interface NTLNTwitterClient : NTLNOAuthHttpClient {
#else
@interface NTLNTwitterClient : NTLNHttpClient {
#endif
int requestPage;
NSString *screenNameForUserTimeline;
BOOL pa...
I have an Xcode project with seven targets, corresponding to seven iPhone apps. That number may increase. A lot of the targets use a lot of the same classes.
I have reproduced portions of the app delegate below. For purposes of this post, I have renamed the targets target1 through target7. I have setup corresponding macroes mTarge...
Hi!,
I use macros to differ the versions but I can't force it to work properly. I used:
#ifdef _IPHONE_4_0
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
#else
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
#endif
and
#if __IPHONE_OS_VERSION_MAX_ALL...
I have a problem wit the software I'm working on.
We are accessing Windows system calls via JNA, and we have to define some Windows structure (Java class that extends the JNA Structure) to be able to access them.
The application has to work with 32-bit and 64-bit architecture, but the problem with the structures is that attributes in t...