f



which compiler was used to compile?

Is there a slick way to invent a constant in a program that tells you
which compiler you used. I distribute both JET and JavaC versions of
my code, and it helps to know on any error dump which version they
were using.

Right now I manually change a static final just before compiling.  I
thought there ought to be something less error prone.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming. 
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
0
roedy4 (647)
10/26/2003 7:11:11 PM
comp.lang.java.programmer 52711 articles. 1 followers. Post Follow

10 Replies
1476 Views

Similar Articles

[PageSpeed] 49

Roedy Green wrote:

> Is there a slick way to invent a constant in a program that tells you
> which compiler you used. I distribute both JET and JavaC versions of
> my code, and it helps to know on any error dump which version they
> were using.
> 
> Right now I manually change a static final just before compiling.  I
> thought there ought to be something less error prone.
> 

Couldn't you just use an Ant task for that?

-- 
Regards,
Christophe Vanfleteren
0
10/26/2003 8:07:16 PM
On Sun, 26 Oct 2003 19:11:11 GMT, Roedy Green wrote:
> Is there a slick way to invent a constant in a program that tells
> you which compiler you used. I distribute both JET and JavaC
> versions of my code, and it helps to know on any error dump which
> version they were using.
> 
> Right now I manually change a static final just before compiling. I
> thought there ought to be something less error prone.

Would have been a simple task for a preprocessor.

On occasion I miss the ability to define symbols on the command line
at compile time, for little things like that.

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e
0
not108 (1253)
10/26/2003 8:33:31 PM
On Sun, 26 Oct 2003 20:07:16 GMT, Christophe Vanfleteren
<c.v4nfl3t3r3n@pandora.be> wrote or quoted :

>
>Couldn't you just use an Ant task for that?

I have done something similar with ordinary bat file that copies two
versions of ConfigForCompiler.java into place and recompiles.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming. 
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
0
roedy4 (647)
10/26/2003 9:18:14 PM
Roedy Green wrote:

> Is there a slick way to invent a constant in a program that tells you
> which compiler you used. I distribute both JET and JavaC versions of
> my code, and it helps to know on any error dump which version they
> were using.
> 
> Right now I manually change a static final just before compiling.  I
> thought there ought to be something less error prone.

It may be over the top, but I have been looking at Jakarta BCEL lately, 
and I'm sure you could use it to programmatically alter the value of 
your compiler identification constant after compilation.  Wrap that up 
in a custom Ant task and you only need to worry about it when working on 
your build files.  For true slickness, wrap it into a custom compilation 
task.


John Bollinger
jobollin@idniana.edu

0
jobollin (1557)
10/27/2003 3:43:01 PM
> Is there a slick way to invent a constant in a program that tells you
> which compiler you used. I distribute both JET and JavaC versions of
> my code, and it helps to know on any error dump which version they
> were using.

One or the other compiler might generate code that puts something in system 
properties?

Is the output of this (to follow) identical the two compilers?

import java.util.Properties;
import java.util.Set;
import java.util.Iterator;

public class Env {
	public static void main(String[] argv) {
		Properties envpp = System.getProperties();
		Set es = envpp.entrySet();
		Iterator tb = es.iterator();
		while(tb.hasNext()) {
			System.out.println("["+tb.next()+"]");
		}
	}
}
0
Thomas
10/27/2003 4:10:49 PM
John C. Bollinger wrote:
> It may be over the top, but I have been looking at Jakarta BCEL lately, 
> and I'm sure you could use it to programmatically alter the value of 
> your compiler identification constant after compilation.  Wrap that up 
> in a custom Ant task and you only need to worry about it when working on 
> your build files.  For true slickness, wrap it into a custom compilation 
> task.

That would probably work, but if you're using Ant, then you can use 
tokens (@compiler@) to accomplish the same thing in a much easier way.

-- 
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
0
cdsmith (3862)
10/27/2003 4:24:55 PM
Chris Smith wrote:

> John C. Bollinger wrote:
> 
>>It may be over the top, but I have been looking at Jakarta BCEL lately, 
>>and I'm sure you could use it to programmatically alter the value of 
>>your compiler identification constant after compilation.  Wrap that up 
>>in a custom Ant task and you only need to worry about it when working on 
>>your build files.  For true slickness, wrap it into a custom compilation 
>>task.
> 
> 
> That would probably work, but if you're using Ant, then you can use 
> tokens (@compiler@) to accomplish the same thing in a much easier way.

Good point.  The downside of that, though, is that it introduces a 
dependency on Ant and the Ant buildfile.  The BCEL solution can be 
implemented without Ant, and the source can be compiled and used in 
another environment in complete ignorance of the existence of a compiler 
identification string (or Ant).  Which choice is better will depend on 
the project requirements, and there might be another approach 
preferrable to both.


John Bollinger
jobollin@indiana.edu

0
jobollin (1557)
10/27/2003 8:50:04 PM
Roedy Green wrote:

> Is there a slick way to invent a constant in a program that tells you
> which compiler you used.

You could wrap your compilers in shellscripts/batch files (or all but one of
them) that prepend a jar/directory to the classpath which contains a special
class with a public static final int or String field.  There's be different
versions of the class (in different jars) for each compiler.  Each runtime
class could check which compiler *it* was compiled with by accessing the field.

    -- chris


0
chris.uppal (3980)
10/28/2003 7:23:39 AM
On Tue, 28 Oct 2003 07:23:39 -0000, "Chris Uppal"
<chris.uppal@metagnostic.REMOVE-THIS.org> wrote or quoted :

>There's be different
>versions of the class (in different jars) for each compiler.  Each runtime
>class could check which compiler *it* was compiled with by accessing the field.

Don't you have to recompile the universe if you use a public static
final in case it has been inlined?

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming. 
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
0
roedy4 (647)
10/28/2003 8:12:58 PM
Roedy Green wrote:

> > There's be different
> > versions of the class (in different jars) for each compiler.  Each
> > runtime class could check which compiler *it* was compiled with by
> > accessing the field.
>
> Don't you have to recompile the universe if you use a public static
> final in case it has been inlined?

There should be no "in case" about it, the values of (arithmetic or String)
final fields are required to be inlined by the Java compiler.  Which is what's
wanted in this case.  E.g, there is no runtime dependency on the "special"
class.

So any individual .class file will "know" which compiler was used to compile it
since the value of the field will have been hard-wired into the "client" class.
That's what I thought you were trying to achieve.

Of course, if you compile your app with a mix of compilers then you'll also get
a mix of different values for the flag (which may or may not be a useful
situation).

I've just tried it, it seems to work fine.

    -- chris



0
chris.uppal (3980)
10/29/2003 11:01:22 AM
Reply:

Similar Artilces:

To compile or not to compile
Is there some benefit in compiling the apache source yourself? -- //Points ------------------------------------------------------------ http://underthebed.homeip.net ...

which compiler compiled?
Is there a way I can tell which compiler compiled an executable? I looked at the file with a hex editor and didn't see anything obvious. Lawrence "Lawrence" <just4me@nowhere.com> writes: > Is there a way I can tell which compiler compiled an executable? Yes with some compilers and some executable formats. E.g. on HP-UX for PA-RISC: $ aCC leak.C $ odump -compunit a.out ... 6 0 ANSI C++ leak.C /tmp ctcom options = -inst compiletime -diags 523 -inline_power 1 -longbranch 2 -unique_strings on -cachesize 256 B...

Compile or not compile?
There's something that sometimes in while it bores me a little bit. How do I know if I need to compile a function/procedure or it will be able to compile "on fly". At the beginning I thought this was related to the paths idl "knew", but this happens for two functions/routines in the same directory. Can someone tell when a function can be runned without be compile? Nuno Oliveira wrote: > There's something that sometimes in while it bores me a little bit. How > do I know if I need to compile a function/procedure or it will be able > to compile &quo...

Compiled or not compiled
I need to distinguish between two situations: one when a Matlab function is run from Matlab command window and the other one when it is run in compiled mode. Any ideas how to do this? Thanks Tomy Duby "Tomy Duby" <tomy.duby@agilent.com> wrote in message news:idq8q8$85k$1@fred.mathworks.com... > I need to distinguish between two situations: one when a Matlab function > is run from Matlab command window and the other one when it is run in > compiled mode. > Any ideas how to do this? HELP ISDEPLOYED. -- Steve Lord slord@mathworks.com comp.s...

Compiling Compiler
Hi there, I need some advice/opinion of the experts out there regarding compilers. I have sun cc compiler that supports 64 bit environment. Now, I compile ACK using this compiler.This should give a compiler that supports 64bit environment. Since the output files are in Solaris format, I compile the ACK source *once again* using the just compiled ACK compiler so that I get Minix object and binary files. Now my questions is that does this 2nd version of ACK be able to produce true 64bit code? Sanky wrote: > Hi there, > > I need some advice/opinion of the experts out there regarding...

To compile or not to compile
Is there some benefit in compiling the apache source yourself? -- //Points ------------------------------------------------------------ http://underthebed.homeip.net ...

compiling using native compiler
When I try to compile python 2.3.4 using SGI's native compiler ../configure --without-gcc followed by make I get error make c++ -o python \ Modules/python.o \ libpython2.3.a -ldl -lpthread -lmpc -lm ld32: WARNING 84 : /usr/lib32/libdl.so is not used for resolving any symbol. ld32: FATAL 9 : I/O error (-lmpc): No such file or directory collect2: ld returned 32 exit status *** Error code 1 (bu21) but I see it in /usr/lib ls -l /usr/lib/mpc -rwxrwxr-x 1 root sys 598996 May 20 17:10 /usr/lib/mpc "SS" ...

Using the GCCSDK to compile a compiler
Hi, Given that there is a port to ARM Linux (Debian) of Novell's Mono .NET package, I'm guessing that it should be possible to compile the source up using the gccsdk (I'm not saying that it would work without being able to generate RISC OS binaries of C# code, but the source should compile). Now, I've been hacking around with Mono for quite a while and know the internals - what I don't know is how I would use the gccsdk to compile up Mono - does anyone have any hints or tips for doing it? I'll need Peter's config scripts, but there in lies a potential problem - Mo...

compiling Qt .... compiling Qt ....compiling Qt.... compiling Qt
I got myself new kernel from kernel.org... make xconfig needs Qt (new system). So I got new Qt source this afternoon. It is still compiling.... Who said MS is bloat has not done this. What does Qt do? Dunno, how about xforms for xconfig? On Thu, 02 Feb 2006 19:18:09 +0000, Jan Panteltje wrote: > Dunno, how about xforms for xconfig? Why not curses based? menuform -- Hilsen/Regards Michael Rasmussen http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917 On a sunny day (Thu, 02 Feb 2006 21:55:33 +0100) it happened Michael Rasmussen <mir@miras.or...

java.lang.IllegalStateException: No Java compiler available
tearing my hair out on this one.Thuis started as an upgrade issue till i realised that my un-usedtomcat5 installation didn't work either with my test jsp.I have, in desparation, un-installed all java / tomcat libs and re-installed only those required to get thetomcat6-6.0.14-1jpp.noarch.rpm (and the band-waggon) loadedfirst I installed java_app_platform_sdk-5_02-linux.binthis shows (after I set alternatives to point to the /opt/SDK/jdkdirecrtory)[root@squirrel ~]# javac -versionjavac 1.6.0java shows the same.I have set the following in profileCLASSPATH=$JDKHOME:$JDKHOME/lib/tools.jarJAVA_H...

how to compile in c++ using smc compiler
hi all, i was using the smc state machine compiler..i tried to compiler the example prog in the manual in java.. it ran with out any error.. but when i tried to compile in c++ i got errors the command i used was java -jar Smc.jar -c++ -d turnstile Turnstile.sm - "%header" missing.. can anyone please help me out ...

compile directive for conditional compile for Java 1.4 versus Java 5
Does a way exist to instruct the Java compiler to compile code onlyif a certain version of Java is supported? For example, I may want tomeasure with milliseconds in Java 1.4 or nanoseconds if I'm running inJava 5.import java.io.IOException;public class JVMLoadTimeRunner { public static void main(String[] args) { long start = System.currentTimeMillis(); // only compile this linein Java 1.4 //long start = System.nanoTime(); // only compile this line in Java5 try { Process newP = Runtime.getRuntime().exec( cmd ); newP.waitFor(); long end = System.currentTimeMillis(); System.out....

Can i use a compiler A to build an application that uses libraries built with compiler B ?
Hi I am facing a problem to build a c++ application. It uses libraries that are build with gcc. The libraries are C libraries and not C++ libraries( and i cannot build these C libraries using C++ compiler because i don't have the source code) The application that i am trying to build is being built with CC compiler of Sun on Solaris and the application is C++ application. I am facing linker errors.( of course the C headers provided with C libraries are using extern "C") My conjecture is that this is due to use of different compilers to build the application and the libraries ...

program that compiles in C compiler but not in C++ compiler
Hi, I need a small program that compiles in C compiler but not in C++ compiler. Thx in advans, Karthik Balaguru KBG <karthik.balaguru@lntinfotech.com> wrote: > I need a small program that compiles in C compiler but not in C++ > compiler. No problem, just send $10 to paypal@zevv.nl and I'll do your homework for you. -- :wq ^X^Cy^K^X^C^C^C^C KBG said: > Hi, > > I need a small program that compiles in C compiler but not in C++ > compiler. Can you think of any syntactic differences between C and C++? For example, what about keywords? They are very, very sen...

Web resources about - which compiler was used to compile? - comp.lang.java.programmer

Compiler - Wikipedia, the free encyclopedia
... , or external linking . The most common reason for wanting to transform source code is to create an executable program. The name "compiler" ...

Compiler - Wikipedia, the free encyclopedia
"Compile" and "compiling" redirect here. For the software company, see Compile (publisher) . For other uses, see Compilation . This article has ...

Facebook Open-Sources HipHop PHP Compiler Software
Earlier this morning, Facebook officially made their new PHP “compiler,” called HipHop, available as open source software. In the blog post by ...

Art in the Age of Matter Compilers
jurvetson posted a photo: Sheba may be the harbinger of art in the digital age — a mathematical sculptor with digital matter. She manipulates ...

Interpreters and Compilers (Bits and Bytes, Episode 6) - YouTube
This animation explains the difference between interpreters and compilers. It is from Episode 6 of the classic 1983 television series, Bits and ...

Typesafe cofounder forking Scala compiler
The main contributor to the Scala compiler, Paul Phillips, has announced on GitHub that he is forking the compiler to “fix some of the innumerable ...

Does Apple's new developer agreement ban Adobe's Flash-to-iPhone compiler?
Given that any kind of formal truce between Apple and Adobe was essentially blown out of the water by Steve Job's very public slating of Flash ...

Apple seeds devs with Safari 5.2 for Lion, Xcode 4.4 with new LLVM compiler
... to the general public this summer. Among the new features: According to Apple, Xcode 4.4 includes an editor for Collada 3D files, compiler support ...

NVIDIA and Continuum Analytics Announce NumbaPro, A Python CUDA Compiler
... are announcing that they are bringing Python support to CUDA. Specifically, Continuum Analytics’ will be introducing a new Python CUDA compiler, ...

IntelliJ Releases IDEA 12, Brings Improved UI, New Compiler Mode, Android UI Designer, And More
I'm not going to pretend to be a developer here, and I'll openly admit that the bulk of what IDEA 12 does is over my head. However, I do understand ...

Resources last updated: 2/3/2016 4:45:06 PM