🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #19917

Native Methods and Borland C++

#19917
From: Philippe Thiran
Date: Tue, 25 Nov 1997 00:00
65 lines
1972 bytes
Hi,

I have a problem with native methods. I use Borland C++ version 4.52 to
compile my .c++ file into a .dll file. The problem is the probem
presented in the SUN JAVA tutorial (the Prompt.java problem).
In the header, I include the jni.h file and prompt.h (like in the SUN
tutorial). When I compile my C++ project, I have compilation errors in
my Prompt.h and also in my Prompt.c like this :

Prompt.h :
*********

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Prompt */

#ifndef _Included_Prompt
#define _Included_Prompt
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     Prompt
 * Method:    getLine
 * Signature: (Ljava/lang/String;)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_Prompt_getLine
(JNIEnv *, jobject,
jstring);
<------------- Erreur Prompt.H : 'Java_Prompt_getLine' is not a
parameter in function __declspec

#ifdef __cplusplus
}
#endif
#endif


Prompt.c
*******

#include <stdio.h>
#include <jni.h>
#include "Prompt.h"

JNIEXPORT jstring JNICALL
Java_Prompt_getLine(JNIEnv *env, jobject obj, jstring prompt)
<-------------Errors : Declaration was expected in function __declspec;
Undefined symbol 'env' in function __declspec; Undefined symbol 'prompt'
in function __declspec


{
 char buf[128];
 const char *str = (*env)->GetStringUTFChars(env, prompt, 0);
 printf("%s", str);
 (*env)->ReleaseStringUTFChars(env, prompt, str);
 scanf("%s", buf);
 return (*env)->NewStringUTF(env, buf);
}

What is the error ????

Thanks.
Technical Details
Message-ID: <347ADB55.7DFE8579@info.fundp.ac.be>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,bf469ddf9833b941
X-Google-Attributes: gidf74b3,public
From: Philippe Thiran <pth@info.fundp.ac.be>
Subject: Native Methods and Borland C++
Date: 1997/11/25
Message-ID: <347ADB55.7DFE8579@info.fundp.ac.be>
X-Deja-AN: 292526233
X-Priority: 3 (Normal)
Organization: University of Namur
Newsgroups: borland.public.jbuilder.java.language