Bonjour tout le monde,

Alors voilà j'ai un problème de char nomvariable :1.

Code du .h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED
#include <stdio.h>
typedef signed char INT8;
typedef short       INT16;
typedef int         INT32;
typedef unsigned char  UINT8;
typedef unsigned short UINT16;
typedef unsigned int   UINT32;
 
typedef union {
	INT32  i;
	UINT32 u;
	float  f;
	char * s;
} Value;
 
typedef struct IoDyn {
    UINT8 init:1;
    Value value;
	UINT8 def:1, // io defined
		  // when server: value received from client
		invalid:1, //
		overflow:1;
	} IoDyn;
 
void plop(IoDyn *io);
#endif // TEST_H_INCLUDED
code du .c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
#include "Test.h"
 
 
void plop(IoDyn *io){
    printf("\n\n init %d  def %d invalide %d   overflow %d    value %s  \n\n",io->init,io->def, io->invalid,io->overflow,io->value.s);
}
code java :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testj;
 
import com.sun.jna.Native;
import testj.TestJ.StructureProtocol.Value.ByValueValue;
 
/**
 *
 * @author Entreprise
 */
public class TestJ {
    public interface StructureProtocol extends com.sun.jna.Library{
        public static class Value extends com.sun.jna.Union{
            public static class ByValueValue extends Value implements com.sun.jna.Union.ByValue{ };
            public int i;
            public int u;
            public float f;
            public String s = null;
            public static class ByReferenceValue extends Value implements com.sun.jna.Union.ByReference{ };
        }
 
        public static class IoDyn extends com.sun.jna.Structure {
            public static class ByValueIoDyn extends IoDyn implements com.sun.jna.Structure.ByValue { };
            public boolean init;
            public ByValueValue value = new ByValueValue();
            public boolean def,invalid,overflow;
            public static class ByReferenceIoDyn extends IoDyn implements com.sun.jna.Structure.ByReference {
            };         
        }
 
        public void plop(StructureProtocol.IoDyn.ByReferenceIoDyn io);
    }
 
    static {       
        System.setProperty("jna.library.path","."); 
    }
 
 
    private StructureProtocol lib;
 
    public TestJ(){
        this.lib = (StructureProtocol) Native.loadLibrary("Structure", StructureProtocol.class);
    }
 
    public StructureProtocol getLib() {
        return lib;
    }
 
    public static void main(String[] args) {
        TestJ t = new TestJ();
        StructureProtocol.IoDyn.ByReferenceIoDyn io = new StructureProtocol.IoDyn.ByReferenceIoDyn();
        io.def = true;
        io.init = false;
        io.invalid = false;
        io.overflow = true;
        io.value.s = " Salutttttttttttt";
        io.value.setType(String.class);
        t.getLib().plop(io);
    }
}
[/QUOTE]
 
Reponse du Main :
[QUOTE] init 0  def 1 invalide 1   overflow 1    value  Salutttttttttttt
Si dans ma structure je mes deux signed char :1 qui se suivent, alors tout le reste de la réponse est erroné sauf comme vous pouvez le voir si je sépare par quelques choses.

Est-ce que vous comprenez et est-ce que quelqu'un peut m'aider?

Pour moi, c'est une erreur de mapping entre la structure Java et C...Comment le résoudre...