Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: preprocessor idea Date: Thu, 13 Oct 2011 18:35:10 +0200 Lines: 57 Message-ID: <9foia2FjbkU1@mid.individual.net> References: <4e94ce75$0$284$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: individual.net 8n2zChI2EcUnYcdQBNpd4w4oEy3jGeRzdKDC0xpUKIcP+1c6k= Cancel-Lock: sha1:RFZFenLCAZIMEEjxi1LvhxZvABM= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: <4e94ce75$0$284$14726298@news.sunsite.dk> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8763 On 12.10.2011 01:17, Arne Vajh=F8j wrote: > On 10/11/2011 2:19 PM, Philipp Kraus wrote: >> I use within my Java code different external libraries (DLL), so I hav= e >> create a string array with their names >> so the libraries can be load with System.load / System.loadLibrary. >> >> I build the libraries (C++ code) with a toolchain and I use a lot of >> preprocessor commands within >> the C++ code, so I can enable or disable some function and so the usin= g >> of the libraries eg: >> >> c++: >> #ifdef lib1 >> #endif >> >> #ifdef lib2 >> #endif >> >> So my Java code must load lib1 and lib2 if both defs are set. Java doe= s >> not support any preprocessor >> flags, but in this case I need a tip for creating a flexiable Java cod= e >> during the class is compiled >> (eg: ifdef1 =3D true =3D> String[] javaarray =3D {"lib1"}). Do you kno= w any >> idea for this problem? > > Run the Java code through the C preprocessor with the same defines. > > String[] javaarray =3D { > "None" > #ifdef lib1 > ,"lib1" > #endif > #ifdef lib1 > ,"lib1" > #endif > }; I do not think it's worthwhile to open that can of worms for this=20 decision. After all getting rid of the CPP is one of the major=20 advantages of Java over C++ (even Stroustrup regrets not having ripped=20 it out of C++) and complicating the Java build process just for that=20 decision seems too heavy - especially since there are other solutions=20 available. Kind regards robert --=20 remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/