09-24-2009 12:59 PM
im getting this error 1>c:\documents and settings\z1083774\desktop\keith_voice\keith_voice\keith_voice\keith_voice.h(58) : fatal error C1004: unexpected end-of-file found
***************************************
#include <atlcom.h>
#else
#define KEITH_VOICE_API __declspec(dllimport)
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
//#ifdef
#ifdef __cplusplus
extern "C" {
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
class KEITH_VOICE_API CKEITH_VOICE {
public:
CKEITH_VOICE(void);
// TODO: add your methods here.
extern KEITH_VOICE_API int nKEITH_VOICE;
KEITH_VOICE_API int fnKEITH_VOICE(void);
}
// all your function prototype go here
// ...
// end of extern C block if a C++ compiler is used
#endif __cplusplus
**********************************************
09-24-2009 02:13 PM
Darnell:
Whenever you get an unexpected end-of-file found message from a compiler, the first thing to check is your block constructs to make sure you have matching {}.
In the code you posted, you have two opening braces {, but only one closing brace }.
When you're using the #ifdef __cplusplus statement, you don't typically include a whole block of code, you just wrap the extern "C" statement, and separately its closing brace. Check the examples in the links I posted earlier to see how this is done.
As I also mentioned earlier, you don't want to declare C++ code as extern "C". It doesn't make any sense to declare a class extern "C" as you seem to be doing. The only things you want to extern "C" are your wrapper functions, as I suggested earlier.
09-24-2009 03:21 PM
im still getting the same thing now, when i put the close braces.
and also when you just export your function, do you mean the function call or the prototypes
where to put the headerfiles, do i put them in the wrapper?
************************************************
#ifdef KEITH_VOICE_EXPORTS
#define KEITH_VOICE_API __declspec(dllexport)
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#else
#define KEITH_VOICE_API __declspec(dllimport)
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
//#ifdef
#ifdef __cplusplus
extern "C" {
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
// all your function prototype go here
// ...
// end of extern C block if a C++ compiler is used
}
#endif __cplusplus
09-24-2009 05:17 PM
Darnell:
You're still not using extern "C" as I described in the links I posted earlier. Go back and look at those links.
#if is different than if() in that you need an #endif for each #if.
You have two #if's and only one #endif. So the compiler gets to the end of the file still looking for another #endif that's not there.
Use braces to block the statements you want affected by #if.
Here is some more information on exporting functions from a Viusal Studio DLL:
http://msdn.microsoft.com/en-us/library/16ya5xae(VS.80).aspx
The wrapper functions will be defined in your CPP files. You will export the functions (see the MSDN link above), and include the prototypes of the exported functions in a .h file that your CVI program will #include.
09-24-2009 05:48 PM
okay i started all over to make sure i was following what you were doing, i had to start over from scratch,
check this see if this is what you are talking about.
09-24-2009 07:07 PM
I think im almost there, i have everything you say to do, now for im getting a alot of errors pertaining to one header file
you can check the project thats in CVI that i attach
09-25-2009 12:45 AM
Darnell:
Please remember that this is a LabWindows/CVI forum, not a C++ forum.
I'm not sure what you would like us to do when you post a 3Meg project and say "check this see if this is what you are talking about". Do you have a specific question?
How can I know where to start when you say "im getting a alot of errors pertaining to one header file" ? What errors? What header file?
Your best chance for success on this forum is if you ask a specific question about CVI.
09-25-2009 01:16 AM
i got the c++ part right it just when i get to cvi to call the functions from c++ , i get errors, im going to post a screen shot of the erros i get thats better.
OK CHECK THE ATTACHMENTS ,I POSTED THE ERRORS IN SCREEN SHOTS, AND THEN THE C++ C FILE AND THE HEADER FILE IM GOING TO COPY AND PASTE
***********************************************
#ifndef _KEITH_SPEAK_H_
#define _KEITH_SPEAK_H_
//#include <iostream>
#define DLL_EXPORT
#define KEITH_FUNCTION_VOICE __declspec(dllexport)
extern int __cdecl FUNCTION_VOICE(void);
#ifdef __cplusplus
extern "C" {
#endif
KEITH_FUNCTION_VOICE int FUNCTION_VOICE (void)
extern int __cdecl FUNCTION_VOICE(void);
// prototypes of functions exported for CVI to call
#ifdef __cplusplus
}
#endif
09-25-2009 03:05 AM
darnell wrote:
"im getting this error 1>c:\documents and settings\z1083774\desktop\keith_voice\keith_voice\keith_voice\keith_voice.h(58) : fatal error C1004: unexpected end-of-file found"
this is not a visual studio forum... but sometimes (often) this error is related to precompiled headers, either due to a badly formed project or a file you deleted (stdafx.h ?): turn off precompiled headers in the project options or recreate your project from scratch (or learn how precopiled headers work and correct the real problem)
12-03-2009 01:52 PM
Although it is in LabVIEW you may want to consider taking a look at something I created, "LabVIEW Speak"
The entire code base is open and I'm using the .NET API so perhaps you can see how I accomplish some of these actions that you're trying to work through.
Article Posting: http://zone.ni.com/devzone/cda/pub/p/id/909
Getting Started Videos: http://decibel.ni.com/content/groups/labview-apis/blog/2009/11/19/labview-speak--programming-lv-thro...
This program does a variety of things out of the box, but is also intended to act as an abstraction layer between the user and the Microsoft .NET speech API.
I haven't read the whole thread, but this tool allows you to make a command set array of strings, send it to the LVSpeak Engine, and receive LV events when one of the commands is detected.
-Norm