expected unqualified-id

Hello,

I am getting the following error in my .h file due to which the compiler doesnt recognize the function in the .cpp file:

In file included from Plc.cpp:1:
Plc.h:27: error: expected unqualified-id before string constant
Plc.cpp:12: error: no ‘jint Plc::Java_Plcio_open(JNIEnv*, __jobject*, __jstring*)’ member function declared in class ‘Plc’

Please advise what can be done.

Regards,

H

Plc.h
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
#ifndef _PLC_H
#define _PLC_H

#include<iostream>
#include<string>
#include<vector>
#include<plc.h>
#include<jni.h>


//#include "Plcio.h"



typedef PLC* plcPointer;

class Plc{

public:
	Plc() { }
	Plc(const std::string &plctype, const std::vector<int> &data):_plctype(plctype),_data(data) {}



  
  #ifdef __cplusplus
  extern "C" {   // ---------> error here
  #endif
  	JNIEXPORT jint JNICALL Java_Plcio_open (JNIEnv *env, jobject jobj, jstring name) ; 
   #ifdef __cplusplus
 }
  #endif

	int close();
	int read();
	int write(std::string &memoryAddress);


private:
	plcPointer _ptr;
	const std::string _plctype;
	std::vector<int> _data;

};
C doesn't support classes, so there are no situations where extern "C" inside a class is valid. Move the declaration to global scope.
Topic archived. No new replies allowed.