2 messages in net.java.dev.jna.usersRe: [jna-users] Defining & Maintainin...
FromSent OnAttachments
Kunal ShahOct 27, 2008 3:34 pm 
Wayne MeissnerOct 27, 2008 4:21 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Defining & Maintaining constantsActions...
From:Wayne Meissner (wmei@gmail.com)
Date:Oct 27, 2008 4:21:13 pm
List:net.java.dev.jna.users

In general, you're stuck with handcoding constants. Any header file that changes its constants will also break any C program linked against the library, unless it is recompiled with each change.

One way to generate java constants is constantine (http://kenai.com/projects/constantine/), which uses some JRuby scripts to convert C constants into java Enums. The scripts can be re-purposed to scan any header file and generate java Enums from them.

2008/10/28 Kunal Shah <kuna@gmail.com>:

In C: #define UNKNOWN_TYPE -1

In Java: public static final int UNKNOWN_TYPE = -1;

If the constant changes (:() for any reason or somebody adds a new constant, then the Java code also needs to be updated too. How to define the same constants in Java such that we can reduce this kind of duplication?