Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » problem with <sapi.h>, text to speech library
problem with <sapi.h>, text to speech library [message #50664] Sat, 01 December 2018 11:33 Go to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

I am able to compile and run the following not UPP code within Theide after linking Ole32.lib and SAPI.lib

#include <iostream>
#include <string>
#include <ctime>
#include <sapi.h>

//type something in to have it spoken!
//enter quit to exit
int main()
{
	 ISpVoice * pVoice = NULL;

    if (FAILED(::CoInitialize(NULL)))
        return EXIT_FAILURE;

    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);    
	if(SUCCEEDED(hr))
	{		
		std::wstring in = L"";

		while( std::getline(std::wcin, in) && in != L"quit") {						
		
			hr = pVoice->Speak((LPCWSTR)in.c_str(), NULL, NULL);        
		}
	
		pVoice->Release();
        pVoice = NULL;
	}
    ::CoUninitialize();

	return EXIT_SUCCESS;
}


However I cannot compile the same code within my U++ program.

c:\program files (x86)\windows kits\10\include\10.0.17134.0\um\ocidl.h (2918): error C2061: errore di sintassi: identificatore 'CY'

The error appear at the include of

#include <sapi.h>

In fact I can comment the relevant code and let stay alone the include to let appear the same problem.
After googling it seems that the problem is that the compiler is confused by several previous includes. Here is my U++ includes that could collide with <sapi.h>

#include <CtrlCore/CtrlCore.h>
#include <CtrlLib/CtrlLib.h>
#include <GridCtrl/GridCtrl.h>
#include <Report/Report.h>
#include <RichEdit/RichEdit.h>
//#include <Web/Web.h>
#include <PdfDraw/PdfDraw.h>
#include <plugin/ftp/ftp.h>
#include <plugin/pcre/Pcre.h>
#include <plugin/jpg/jpg.h>
#include <RepGen/RepGen.h>
#include <MySql/MySql.h>
 
#define IMAGECLASS    Vega8Img     
#define IMAGEFILE     <Vega8/Vega.iml>
#include <Draw/iml_header.h>  

#define SCHEMADIALECT <MySql/MySqlSchema.h>
#define MODEL <Vega8/db.sch>
#include <Sql/sch_header.h>

using namespace Upp;


Does anybody tried the <sapi.h> inside his app? Any suggestion?

Thanks,
Luigi
Re: problem with <sapi.h>, text to speech library [message #50665 is a reply to message #50664] Sat, 01 December 2018 18:50 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3041
Registered: August 2008
Ultimate Member
Hello Luigi

I think I had the same problem with some includes in Bazaar/Functions4U.

The trick was this:
#define CY win32_CY_

#include <winnls.h>
#include <winnetwk.h>

#include <wincon.h>
#include <shlobj.h>

#undef CY


Best regards
IƱaki

[Updated on: Sat, 01 December 2018 18:50]

Report message to a moderator

Re: problem with <sapi.h>, text to speech library [message #50666 is a reply to message #50665] Sat, 01 December 2018 23:13 Go to previous message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
koldo wrote on Sat, 01 December 2018 18:50
Hello Luigi

I think I had the same problem with some includes in Bazaar/Functions4U.



Hi Koldo,

thanks, it worked! Such fix looks like black magic Smile

Luigi
Previous Topic: PostgreSQL under Windows
Next Topic: error: expected unqualified-id before '=' token
Goto Forum:
  


Current Time: Sat Dec 07 13:25:10 CET 2019

Total time taken to generate the page: 0.01066 seconds