|
You don't need to specify the arguments in the .def file. When you say "incorrect result" what do you mean? Keep in mind, that you need to take Joaquín's comments into account (by using __stdcall instead of __cdecl).
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
I had a slight error in the calling VB program which was making the numerical result incorrect. Once I removed the argument list from the def file and fixed the VB problem, it worked fine.
My next task is to find a compiler for this user who wants to be able to compile the Dll but refuses to install V Studio. SO far the gcc compiler I've looked into (I'm on windows) doesnt tell me how to compile a dll given a .c and a .def file.
Anyways, the coding problem has been resolved, so I thank you for your input.
Appreciate your help,
ns
|
|
|
|
|
Hi,
I have a small question regarding pointers.
I have an 2D array of ints like:
static int ERBaCoeff_22050[2][7] = {
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10}};
I try to do something like this:
int ** a = ERBaCoeff_22050;
The compiler throws an error. Saying cannot convert a int[2][7] to a int**
I thought this was a legal assignment. I even tried something like:
int ** a = &ERBaCoeff_22050;
but no luck.
Also,
int * some = &ERBaCoeff_22050[0][0];
int ** a = &some
This works. But I cannot traverse the array beyond the forst row...
i.e. a call to a[1][1] fails, but a [0][7] works
It works when I do:
char *ptr;
char arrayChars[8] = {'F','r','i','e','n','d','s','\0'};
ptr = arrayChars;
What am I doing wrong??
I would greatly appreciate any help you guys can give me.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
A couple of things strike me.
1. In your first declaration
int **a=ERBaCoeff_22050
You are trying to set a pointer to a pointer to an array. This wont work as the array is not a pointer.
That is why
pankajdaga wrote:
int * some = &ERBaCoeff_22050[0][0];
int ** a = &some
works. You are first setting an int pointer to point to the array then setting the a pointer to point to the pointer. This is the only way you can do it.
2. You cant address the second row because the compiler doesnt know how big the rows are in the array. while a[0][n] always refers to the first row a[x][y] refers to row x and requires the compiler to do the math to find the correct row, it cant do this if it doesnt know the size of the rows.
Look at it like this an int* is a row of int with as many as you like so a[10] and a[0][10] are the same thing all the way to a[0][infinte] but given that the row is infinte in length what does a[1][1] actually mean.
I think this explination is correct. Someone correct me if im wrong
I hope this helps.
|
|
|
|
|
Hi,
Thanks for the explanation. Helps a lot
However, my problem is what is the best way to traverse such an array. I need to pass it to another function and I do not want to make a copy of the array. I want to pass a reference and access the elements. I am still trying to figure out the best way to do so.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Have a lookie at this[^].
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Hi,
Yeah, I figured out the declaring part. I am having trouble traversing it in a function when it is passed as an argument to it.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
It doesn't really seem like you need a pointer to a pointer. I would use a simple wrapper class for a 2d vector and use that. Here's a demo console app showing what I mean:
#include "stdafx.h"
#include <vector>
class InnerArray
{
public:
std::vector<int> y_value;
};
class CMyArray
{
public:
CMyArray(const int& x_size, const int& y_size)
{
nx = x_size;
ny = y_size;
for(int x = 0; x<x_size; x++)
{
x_value.push_back(new InnerArray);
for(int y=0; y<y_size; y++)
{
x_value[x]->y_value.push_back(0);
}
}
};
int GetData(const int& x_, const int& y_) const
{
return x_value[x_]->y_value[y_];
};
void SetData(const int& x_, const int& y_, int data)
{
x_value[x_]->y_value[y_] = data;
};
virtual ~CMyArray()
{
x_value.clear();
};
private:
int nx;
int ny;
std::vector<InnerArray*> x_value;
};
void MyFunc(CMyArray cma);
int main(int argc, char* argv[])
{
int x=0;
int y=0;
CMyArray ERBaCoeff_22050(2,7);
for(x=0; x<2; x++)
{
for(y=0; y<7; y++)
{
ERBaCoeff_22050.SetData(x,y,((x+1)*(y+1)));
}
}
MyFunc(ERBaCoeff_22050);
return 0;
}
void MyFunc(CMyArray cma)
{
printf("\n\n");
for(int x=0; x<2; x++)
{
for(int y=0; y<7; y++)
printf("\nValue Of ERBaCoeff_22050[%d][%d] = %d", x,y,cma.GetData(x, y));
}
printf("\n\n");
}
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Hi again,
I know I could use another container or even encapsulate the data in a small class and push it as an object. I actually wanted to learn how to do pointer math without any problems. Sometimes I need some very fast performance (I am a sound engineer, by profession) and in those situations I cannot use such containers.
Thanks for your help anyways. I do agree, in normal situations it is a better solution and also a more OO one
Pankaj
Without struggle, there is no progress
|
|
|
|
|
pankajdaga wrote:
Thanks for your help anyways.
NP.
Sorry I couldn't help Good luck.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Of course you did. Sorry could not implement your solution in this situation. Do not take it personally
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Hi,
I'm moving my app from the VC6 environment to the VS.net environment and while the app comiles I'm confused about the behaviour of the Class View window.
All of my typedefs now appear as enreies of the __unnamed_XXXXXXX_1 variety.
Thus:
typedef struct {<br />
DWORD state[4]; <br />
DWORD count[2]; <br />
unsigned char buffer[64]; <br />
} MD5_CTX;
Results in :
__unnamed_2a850dbe_1
and:
typedef enum<br />
{<br />
POOL_MASTER,<br />
POOL_SLAVE,<br />
}POOL_THREAD_TYPE;
in: __unnamed_ddd563c5_1
Does anyone know why its doing that and how I stop it ?
|
|
|
|
|
Hail
Try to use full typedef notation, i.e.
typedef struct|enum type_name {<br />
...<br />
...<br />
} name;
In you case it will be something like
typedef struct _MD5_CTX {<br />
DWORD state[4]; <br />
DWORD count[2]; <br />
unsigned char buffer[64]; <br />
} MD5_CTX;
Hope it'll help.
Valery
|
|
|
|
|
Thanks for that, you were right.
Your response is much appreciated.
|
|
|
|
|
I need know temperature on CPU and Mother Board.
How I can Get this?
|
|
|
|
|
Perhaps You find sth in the ACPI specs. But I am not sure if this was standardized.
Otherwise by a thermoelement which can be read out via RS232. This always works
|
|
|
|
|
How can I add a checkbox to an Open File dialog? (CFileDialog class)
I tried deriving a class from it... but that's about as far as I got
|
|
|
|
|
try this[^] article
Kannan
|
|
|
|
|
|
Hello colleague-CP'ers,
Situation:
I need to switch a listbox from single selection mode to multiple selection mode.
I use the code found at
http://www.codeproject.com/combobox/RecreateListBox.asp[^]
that in fact recreates the listbox.
Problem:
After recreating my listbox (that contains a lot of items) it doesn't have a scroll bar anymore. The scroll bar is GONE!
Anybody an idea?
Anybody had the same?
Other ideas to make a single selection list box a multiple selection one and vice versa?
Geert
|
|
|
|
|
I have developed an application using VC6.0.Its a dialog based application when I run this on XP it never resizes my dialog it remains only in two modes either maximized mode or minimized...what could be the problem...If somebody has some idea please do let me know.
Thanks in advance
|
|
|
|
|
So it appears as if it's remembering the previous size in the registry or somewhere. Since it's your app, you should know where (or at least be able to find out). So go there and clear those settings.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hey Alvaro,
Can you please elaborate on the settings you are talking about that I need to clear???
The problem comes, once I minimize the window and then I click it to restore, the icon turns into a pressed/highlighted icon but window doesn't come up then I have to right click and select maximize from the menu then only I can view it.
This problem is there in XP and works fine on all other windows versions.
My feeling is that it forgets it's previous size. I am not able to figure out whether this my programming bug or Windows problem.
Both the ways I do not have any clue as what to do
It's our customers requirements and have to fix it urgently. I am stuck I would appreciate if someone can help me on this or point me to some mailing list/discussion forum etc.
Thanks
Prateeti
|
|
|
|
|
I have developed an application using VC6.0.Its a dialog based application when I run this on XP it never resizes my dialog it can only be in two modes either maximized mode or minimize...what could be the problem...If somebody has some idea please do let me know.
Thanks in advance
|
|
|
|
|
how to get motherboard serial number using vc++.
I want to generate a unique hardware id using vc++.
can anyone help me..
|
|
|
|