Error during build: 'const char [34]' to 'STRCTYPE'

Hi guys,

I am making progress again in calling the LM routines from FORTRAN, by first just trying to create a C subroutine that acts like your "Example.c" Program file.

I get the 3 errors similar to the following one when trying to build the C file with the calls to your DLL, just like in the Example.c file. Here is the error:---->>>Error 3 error C2664: 'IsActivated' : cannot convert parameter 1 from 'const char [34]' to 'STRCTYPE' y:\work\software\fortran\fortran_calls_c\clib\csub.cpp 47 Clib

From the code below, the error refers to this line:HRESULT hr = IsActivated(TA_GUID);---This happens with two other functions that return values from your DLL.

I took your advice and I am not linking with any Static Libs...just the DLL, so the program can be more robust.

Can you help me?

Thank you!!!

--->>> Here is the C-file: (It doesn't have all the calls from your Example.c file)

/*! Copyright (C) 2008 Intel Corporation. All Rights Reserved. !! The source code contained or described herein and all documents related to the source code ! ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the ! Material remains with Intel Corporation or its suppliers and licensors. The Material is ! protected by worldwide copyright laws and treaty provisions. No part of the Material may be ! used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, ! or disclosed in any way except as expressly provided in the license provided with the ! Materials. No license under any patent, copyright, trade secret or other intellectual ! property right is granted to or conferred upon you by disclosure or delivery of the ! Materials, either expressly, by implication, inducement, estoppel or otherwise, except as ! expressly provided in the license provided with the Materials.*/

/* C routine called by Fortran main program**** Converts integer input argument to text, appends** the text to string input argument and stores the** result in the string output argument*/

#include <stdio.h>#include "Y:\Work\Software\FORTRAN\Fortran_Calls_C\TurboActivate.h"

#ifdef _WIN32 #include <tchar.h>#else #define _T(x) x typedef char TCHAR;#endif

#define TA_GUID _T("18324776654b3946fc44a5f3.49025204")

extern "C" void c_routine ( int int_arg, char* input_text, char* output_text )

{

sprintf(output_text,"%s%i ",input_text,int_arg);

//START some of the LIME LM "Example.c" lines:

HRESULT hr = IsActivated(TA_GUID);

if (hr == TA_OK) { TCHAR * featureValue;

printf("YourApp is activated! Enable any app features now.\n"); }

else // not activated { uint32_t trialDays;

printf("Not activated: hr = %d\n", hr);

// Start or re-validate the trial if it has already started. // This need to be called at least once before you can use // any other trial functions. hr = UseTrial(TA_SYSTEM);

// Get the number of trial days remaining. hr = TrialDaysRemaining(TA_GUID, &trialDays);

if (hr == TA_OK) printf("Trial days remaining: %d\n", trialDays); else printf("Failed to get the trial days remaining: hr = %d\n", hr);

//TODO: prompt for a product key (if it's not present) //Note: here we're just hard-coding the product key to show how you // save the product key and try to activation

// Also not we're using the TA_SYSTEM flag. This means the activation will be system-wide. // However calling using the TA_SYSTEM flag (the first time only) requires system-admin privleges. // If your app will never have system admin privleges then you can use the TA_USER flag. hr = CheckAndSavePKey(_T("U9MM-4NJ5-QFG8-TWM5-QM75-92YI-NETA"), TA_SYSTEM); if (hr == TA_OK) { printf("Product key saved successfully.\n");

// try to activate hr = Activate();

if (hr == TA_OK) printf("Activated successfully\n"); else printf("Activation failed: hr = %d\n", hr); } else printf("Product key failed to save: hr = %d\n", hr); }

printf("Hello world.");}

This error is caused because you're using char* strings instead of WCHAR_T* strings. That is, on Windows you must use Unicode (UTF-16) strings on all the TurboActivate function (not ansi char* strings).

Does that make sense?

Wyatt,

Thank you for all you consistent help. First: I don't know if I will need to change anything, but I may be in "wishful thinking" mode. Let me explain:I just got a dummy FORTRAN program to essentially do all the calls in your Example.c file, by just making the "Main" into a C subroutine and then calling that from FORTRAN.

Just a few things:- I kept the DLL, but I needed to make a .LIB that pointed to all the contents. I followed the method in the following website:http colon slash slash adrianhenke.wordpress dot com /2008/12/05/create-lib-file-from-dll/

Then I was able to get a successful compile and build of the system all from VS2008!

The program runs and the "Example.c" calls are made, but now I get the same "wrong output" as I did when I just compiled the Example.c program by itself (NO FORTRAN).

I get the following output:---------------------------------------------------------------------------Microsoft Windows [Version 6.1.7601]Copyright (c) 2009 Microsoft Corporation. All rights reserved.

Y:\Work\Software\FORTRAN\Fortran_Calls_C\Fmain\Release>fmainNot activated: hr = 8Failed to get the trial days remaining: hr = 8Product key failed to save: hr = 8Hello world. Testing...123 ----> this is just my dummy line.........

Y:\Work\Software\FORTRAN\Fortran_Calls_C\Fmain\Release>

---------------------------------------------------------------------------

Why is hr = 8 always? I am basically testing this as if I sent a potential buyer a copy *without* a license file. I want to essential provide a demo and have that countdown my 30 days like I set up.

Like I said, this is exactly what I saw when I just ran the Example.c file all by itself, without going through fortran.

Thank you very much!!

OK, I just put the "Turboactivate.dat" file in the exe directory and I got the following:

Y:\Work\Software\FORTRAN\Fortran_Calls_C\Fmain\Release>fmainNot activated: hr = 7Failed to get the trial days remaining: hr = 7Product key failed to save: hr = 1Hello world. Testing...123

Y:\Work\Software\FORTRAN\Fortran_Calls_C\Fmain\Release>

I guess that is progress, but I'm still confused.

Thank you for all your help!

When this is done, I'd love to clean up my sample FORTRAN - C - LM Project and send it to you for your records.

Well, you can get a full description of every error code in TurboActivate.h. A "7" error code is TA_E_GUID, which means "The version GUID doesn't match that of the product details file.".

This can mean a couple things. Most likely it means you didn't copy & paste the GUID from the same page you downloaded the TurboActivate.dat file (and then pasting it into the #define TA_GUID line in the example C program) .

Does that make sense?

OK, got it. I failed to realize that the values that hr can equal are the error values. I am checking on that now. I know I copied some GUID, but I am absolutely sure that this is user error.

Thank you so much for all your help! It is so nice to get the constant support!

Oren

I had a deeper problem than I thought, and it refers back to the main subject of this post:

const char[34] to STRCTYPE

If I change the two _T() macros to just use the L" " syntax, then it works.

Basically I have to change this line#define TA_GUID _T("xxx.xxx")To this:#define TA_GUID L"xxx.xxx"

AND I have to change this line:hr = CheckAndSavePKey(_T("U9MM-4NJ5-QFG8-TWM5-QM75-92YI-NETA"), TA_SYSTEM);To this:hr = CheckAndSavePKey(L"U9MM-4NJ5-QFG8-TWM5-QM75-92YI-NETA", TA_SYSTEM);

For some reason I can not use the _T macro? Why would that be? I want to be as robust as possible with my code, but I have no clue why I have to force ascii...

Once I do this, I get the following output from a dummy run:----------------Y:\Work\Software\FORTRAN\Fortran_Calls_C\Fmain\Debug>fmainNot activated: hr = 1Trial days remaining: 18Product key failed to save: hr = 1Hello world. Testing...123----------------------

Thank you for any insight!

Oren

Once I do this, I get the following output from a dummy run:----------------Y:\Work\Software\FORTRAN\Fortran_Calls_C\Fmain\Debug>fmainNot activated: hr = 1Trial days remaining: 18Product key failed to save: hr = 1Hello world. Testing...123----------------------

Ok, that's a good output. (The reason the key is failing to be saved is because that's an invalid key. Generate a key in your account and use that).

For some reason I can not use the _T macro? Why would that be? I want to be as robust as possible with my code, but I have no clue why I have to force ascii...

My guess is your project has the wrong character set (and thus is using ANSI strings instead of wide Unicode strings).

[attachment=0]set.unicode.char.set.png[/attachment]

Changing to Unicode in the configuration as you showed fixed the issue! Wow, thank you!

About creating a key: Since I only have one to create, can I create it and then "try out" my "licensed" program and then check it back in or destroy the license in any way so I get that license back?

I will buy the monthly subscription once I get a sale so I get more keys. I am hoping for 2 sales in the next 2 months, so I will start with the lowest monthly tier and then move up from there.

Thank you so very much for all you insight and assistance!

Oren

About creating a key: Since I only have one to create, can I create it and then "try out" my "licensed" program and then check it back in or destroy the license in any way so I get that license back?

You can create 10 keys in the free plan.

Thank you so very much for all you insight and assistance!

My pleasure.