|
Hi,
I wish to convert from c# for the following codes contain get_Item & set_Value convertion in C++/Cli.
Code:
private static void SetWIAProperty(IProperties properties, object propName, object propValue)
{
Property prop = properties.get_Item(ref propName);
prop.set_Value(ref propValue);
}
Any guidences will be helpful.
Thanks Again
modified 9-Apr-18 12:19pm.
|
|
|
|
|
How to add columns dynamically to wpf datagrid in mvvm without using dependency proporties
|
|
|
|
|
|
Does anybody know how to detect when option -Gr is in effect? I mean there is (AFAICS)
no built-in define _Gr in such a case.
-- Gisle V.
|
|
|
|
|
Hi,
With the MSVC compiler you can do:
#ifdef _CPPRTTI
#endif
I think with GCC you can do:
#ifdef __GXX_RTTI
#endif
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks, but RTTI and option -GR has nothing to do with option -Gr AFAICS.
-Gr is fastcall and -GR is to enable C++ RTTI.
-- Gisle V.
|
|
|
|
|
Yeah I missed the lower case. (I'm getting old and losing my eye sight.)
On an older version of Visual Studio you would need to parse __FUNCSIG__ with some preprocessor wizardry. This macro is only available inside the function.
Visual Studio 2012 and above supports the latest C++11,C++14 Decltype and Call Expressions[^] version 1.1
You would use it like this:
Callable Objects with different calling conventions[^]
Best Wishes,
-David Delaune
|
|
|
|
|
I need help with this project. anyone who can help?
|
|
|
|
|
|
Hello Guys..
i am about to work on sdk that built in C/C++ ... how i can communicate with it using C# ?
it`s requires C++ language which is hard to learn in a few days...
Real-Time push server in C++ may i use it as un-managed dll`s so i can work on it using C# ?
|
|
|
|
|
Yes, you should be able to create a C++/CLI Assembly (DLL) which exposes functionality to C# via ref classes. Those managed classes can call into the C/C++ SDK to do the necessary work. Reference the C++/CLI assembly from your C# code and call into it... profit!
|
|
|
|
|
Hi everyone!
I created a library with Entity Framework 6 in C# recently, and now I would like to use it with a C++ program. Consequently I though about using C++/CLI to reuse my C# code, translating it easily. Is it a good/logical choice? I'm not sure because I don't know much about C++/CLI.
I'm trying to follow the steps I used to create my C# library. Now I'm stuck with adding the element "ADO.Net Entity Data Model" to my project in Visual Studio 2015. How can I do that?
I couldn't find any tutorial about using Entity Framework with C++/CLI, that's why I'm a bit lost.
Thanks !
|
|
|
|
|
|
Rather than wasting the time of busy professionals, why not give this a try yourself? You might actually learn something (even if that something is that you only know how to start the program off and not how to finish it, showing you where you need to study more). This site is CodeProject, not RentACoder.
This space for rent
|
|
|
|
|
Hi,
I have a server client application using TCP/IP sockets in MFC VS2017. Originally i have written the code in VS2008. Kindly see the below code which sends the data to client. But this same code gives me some problem in MFC VS2017.
In the below code when I assign the value 190.000015f to a local variable, its taking the value whereas when I assign it to the union member variable
UNI.S.fTestValue1 and
UNI.S.fTestValue2 , it showing some junk value. Please help me to fix the problem
unsigned char* CSendValue :: SendLiveValues()
{
union USendLive
{
struct SSend
{
float fTestValue1;
float fTestValue2;
char cChr;
}S;
unsigned char Buffer[LIVEUNISIZE];
}UNI;
memset(UNI.Buffer,0,LIVEUNISIZE);
float fLocalValue;
float fTest;
fTest = 190.000015f;
fLocalValue = fTest; UNI.S.cChr = 'c'; UNI.S.fTestValue1 = fTest; UNI.S.fTestValue2 = 190.000015f;
return UNI.Buffer;
}
|
|
|
|
|
Probably a problem of structure packing / data alignment. With C/C++ structures and unions, member data are aligned by inserting padding bytes. How many bytes are inserted depends on the used compiler options where the default settings depend on the platform (CPU type and bit width).
When sending such structures via network to other systems, you must ensure that sender and receiver use the same packing / alignment. This is usally done by setting the alignment to one byte.
With Visual Studio use the #pragma pack[^] directive:
#pragma pack(push, 1)
union USendLive
{
struct SSend
{
float fTestValue1;
float fTestValue2;
char cChr;
} S;
unsigned char Buffer[LIVEUNISIZE];
} UNI;
#pragma pack(pop) Note that this might fail with existing (old) versions of your server and client. If so and you have to support old versions, you must check which alignment has been used and select that for packing.
BTW:
This forum is for managed C++ / CLI but your post would fit in the C++ / MFC forum.
|
|
|
|
|
I question how you are determining it is wrong. You code does not demonstrate that.
HOWEVER....
You are declaring a data entity on the stack. Then you are RETURNING part of that data entity from the method.
That is ALWAYS wrong.
And I suspect that is your problem.
The calling code also uses the stack. And will reuse exactly the same memory as where you are attempting to put a value if it wants to. For example if you are calling a method to 'print' the returned value in some way. Thus overwriting it. And that would cause a "junk" value either now or in the future.
|
|
|
|
|
i have tried it but it doen't work. It would be great if you could point out my mistake and better if correct it.
#include <stdio.h>
#include <conio.h>
int inc_order(int num[], int count, int i);
int compare(int hole, int value, int num[]);
int main(){
int num[50], n, count, j, i=0;
printf("Number of integers: \t");
scanf("%d", &count);
printf("\nEnter your integers: \n");
for(n=0; n<count; n++){
scanf("%d", &num[n]);
}
inc_order(num, count, i);
for(j=0; j<count; j++){
printf("%d", num[j]);
}
return 0;
}
int i=1;
void inc_order(int num[], int count, int i){
int value, hole;
if(i<count){
value = num[i];
hole = i;
}
compare(hole, value, num);
inc_order(num, count, i++);
}
int compare(int hole, int value, int num[]){
if(hole==0){
num[hole]=value;
return(num[hole]);
}
if(num[hole-1]>value){
num[hole] = num[hole-1];
hole--;
}
compare(hole, value, num);
}
modified 18-Nov-17 15:38pm.
|
|
|
|
|
That is not a proper task for recursion.
|
|
|
|
|
This is the code i came up with but it's too long, how to short it down.
#include <conio.h>
#include <stdio.h>
int main(){
int i=0, j, num[100], count=0, k, hcf[50], min;
printf("Enter your numbers: \n");
do{
scanf("%d", &num[i]);
i++;
count++;
}while(num[i-1]!=0);
min = num[0];
for(j=1; j<=count-2; j++){
if(min>num[j])
min = num[j];
}
int h=0, n[count-1];
for(j=0; j<=count-2; j++){
for(k=1; k<=min; k++){
if(num[j]%k==0){
hcf[h]=k;
h++;
}
}
n[j] = h;
}
int c=0, max[50], z;
for(i=0; i<n[0]; i++){
z=0;
for(j=n[0]; j<h; j++){
if(hcf[i]==hcf[j]){
z++;
}
}
if(z==(count-2)){
max[c]=hcf[i];
c++;
}
}
for(i=1; i<c; i++){
if(max[0]<max[i])
max[0]=max[i];
}
printf("\nHcf : %d\n", max[0]);
return 0;
}
<pre lang="c++"><pre lang="c++"><pre lang="c++"><pre lang="c++"><pre lang="c++"><pre lang="c++"><pre lang="c++">
|
|
|
|
|
You can do most of the work in a single loop.
|
|
|
|
|
can you tell where i can decrease the size of code or how it can be done in single loop ?
|
|
|
|
|
Yes, but this is your homework. Before you start coding try to write things out on paper and look at the best ways to get what you need. See how many things you can do in the first loop. For example, you can check each number to see if it is the smallest or largest as you read them in.
|
|
|
|
|
I am looking at some MSDN documentation and the "C++" code example are empty with the message
"No code example is currently available or this language may not be supported."
Is it because the feature is not available in C++ or that is is just not "documented with code examples"
The thing I am looking at is Enumerable::ToDictionary
see the MSDN documentation :
Enumerable.ToDictionary(TSource, TKey) Method (IEnumerable(TSource), Func(TSource, TKey)) (System.Linq)
There is not C++ example.
Is it possible to convert that code to C++ ?
Thanks.
I'd rather be phishing!
|
|
|
|
|
Maximilien wrote: Is it possible to convert that code to C++ ? Not easily as C++ has no simple IEnumerable class. However you may be able to adapt one of the other STL collection classes. See Standard C++ Library Reference[^].
|
|
|
|