|
VC++ 6 by default only compiles the files affected by the change, unless you have manualy set to up to do otherwise.
(F7 or Build in menu): Compiles (affected files) and Links (Links entire project).
Unless that 1 file is a header that is used in every file, then the whole project should not be being recompiled. But the whole project will be relinked.
If you do not see in the build window
Compiling...
StdAfx.cpp
...
then it is not recompiling the whole project.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
|
Thanks for your answers!! That solved my problem... one of the computers had 2006 in the year configuration...!
I was wasting a lot of time compiling all the files (about 50) everytime I modified one of them... Thanks again!
|
|
|
|
|
Hi,
I have the function defined below, returns Ip without any error:
[code]
double Integral(void)
double j0,j1,H0,H1,p,Ip;
double bessj0(double x);
double bessj1(double x);
int t = 1;
alpha = beta = 2*t*PI; // t = 1
p = sqrt(pow(alpha,2.0)+pow(beta,2.0));
j0 = bessj0(2.0*p);
j1 = bessj1(2.0*p);
H0 = sum0(2.0*p);
H1 = sum1(2.0*p);
Ip = ((PI*p)/2) * ((2*p*j0) + (((PI*p)/2) * ((H0*j1)-(H1*j0))) - j1);
return Ip;
//}
}[/code]
However, I need an array, Ip[] to be returned;
not just one value. I made the following modifications to the code:
[code]
double Integrals(void)
{ double alpha[20],beta[20];
for (int t=1;t<21;t++)
{
double j0[20],j1[20],H0[20],H1[20],p[20],Ip[20];
double bessj0(double x[20]);
double bessj1(double x[20]);
int t = 1;
alpha[t] = beta[t] = 2*t*PI; // t = 1
p[t] = sqrt(pow(alpha[t],2.0)+pow(beta[t],2.0))
+sqrt(pow(alpha[t],2.0)+pow(beta[t],2.0));
j0[t] = bessj0(p[t]);
j1[t] = bessj1(p[t]);
H0[t] = sum0(p[t]);
H1[t] = sum1(p[t]);
Ip[t] = ((PI*p[t])/2) * ((2*p[t]*j0[t]) + (((PI*p[t])/2) * ((H0[t]*j1[t])-(H1[t]*j0[t]))) - j1[t]);
return Ip[20];
//}
}
}[/code]
However, I have 2 errors:
[code]error C2664: 'bessj0','bessj1' : cannot convert parameter 1 from 'double' to 'double []'[/code]
despite having modified the function definitions double bessj0(double x); and double bessj1(double x); to double bessj0(double x[20]); and double bessj1(double x[20]); WITHOUT ANY ERRORS.
viz:
[code]
double bessj0(double x)
//Returns the Bessel function j0(x) for any real x.
{
float x;
double ax,z,xx,y,ans1,ans2,j0;
if ((ax=fabs(x))<8.0) //Direct rational function fit
{
y=x*x;
ans1=57568490574.0+y*(-13362590354.0+y*(651619640.7
+y*(-11214424.18+y*(77392.33017+y*(-184.9052456)))));
ans2=57568490411.0+y*(1029532985.0+y*(9494680.718
+y*(59272.64853+y*(267.8532712+y*1.0))));
j0=ans1/ans2;
}
else
{
z=8.0/ax;
y=z*z;
xx=ax-0.785398164;
ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4
+y*(-0.2073370639e-5+y*0.2093387211e-6)));
ans2=-0.1562499995e-1+y*(0.1430488765e-3
+y*(-0.6911147651e-5+y*(0.7621095161e-6
-y*0.934945152e-7)));
j0=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2);
}
return j0;
}[/code]
to:
[code]
double bessj0(double x[20])
//Returns the Bessel function j0(x) for any real x.
{
double ax[20],z[20],xx[20],y[20],ans1[20],ans2[20],j0[20];
if ((ax[20]=fabs(x[20]))<8.0) //Direct rational function fit
{
y[20]=x[20]*x[20];
ans1[20]=57568490574.0+y[20]*(-13362590354.0+y[20]*(651619640.7
+y[20]*(-11214424.18+y[20]*(77392.33017+y[20]*(-184.9052456)))));
ans2[20]=57568490411.0+y[20]*(1029532985.0+y[20]*(9494680.718
+y[20]*(59272.64853+y[20]*(267.8532712+y[20]*1.0))));
j0[20]=ans1[20]/ans2[20];
}
else
{
z[20]=8.0/ax[20];
y[20]=z[20]*z[20];
xx[20]=ax[20]-0.785398164;
ans1[20]=1.0+y[20]*(-0.1098628627e-2+y[20]*(0.2734510407e-4
+y[20]*(-0.2073370639e-5+y[20]*0.2093387211e-6)));
ans2[20]=-0.1562499995e-1+y[20]*(0.1430488765e-3
+y[20]*(-0.6911147651e-5+y[20]*(0.7621095161e-6
-y[20]*0.934945152e-7)));
j0[20]=sqrt(0.636619772/ax[20])*(cos(xx[20])*ans1[20]-z[20]*sin(xx[20])*ans2[20]);
}
return j0[20];
}[/code]
Is there another way I can re-write the code such that I return THE ARRAY, Ip[]? from the function double Integrals(void)?
THANKS
|
|
|
|
|
If this is a C++ program rather than C, use a vector (or CArray for MFC) rather than an array and return that. Otherwise return the array via a function argument.
Kevin
|
|
|
|
|
Thanks Kevin.
It is a Visual C++ project, w/ MFC. How would I implement your modification in my code already pasted?
|
|
|
|
|
Actually the easiest way to do what you want is just to pass Ip[] as a function argument, e.g.,
void Integrals(double Ip[])
Before you call the function you should initialise the array like this.
double Ip[20] = {0.0}; // set 20 values to 0.0
Then call like
Integrals(Ip);
You probably also want to specify the size of the array as an argument
void Integrals(const int max_size, double Ip[])
and then use that for your loop and array bounds.
Basically your 20 should be replaced by a constant declaration.
Kevin
|
|
|
|
|
You could use a vector or just plain old array.
double* MyFunc()
{
double* pd = new double(SIZE OF ARRAY);
return db;
}
void MyOtherFunc()
{
double* pd = MyFunc();
delete dp;
}
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Thanks for the valuable tips!
Since I'd rather not mess with pointers if I can help it, I called the array in my Bessel functions; viz:
void bessj0(double x[20],double j0[20])
{
double ax[20],z[20],xx[20],y[20],ans1[20],ans2[20];
for (int i=0;i<20;i++)
{
if ((ax[i]=fabs(x[i]))<8.0)
{
y[i]=x[i]*x[i];
ans1[i]=57568490574.0+y[i]*(-13362590354.0+y[i]*(651619640.7
+y[i]*(-11214424.18+y[i]*(77392.33017+y[i]*(-184.9052456)))));
ans2[i]=57568490411.0+y[i]*(1029532985.0+y[i]*(9494680.718
+y[i]*(59272.64853+y[i]*(267.8532712+y[i]*1.0))));
j0[i]=ans1[i]/ans2[i];
}
else
{
z[i]=8.0/ax[i];
y[i]=z[i]*z[i];
xx[i]=ax[i]-0.785398164;
ans1[i]=1.0+y[i]*(-0.1098628627e-2+y[i]*(0.2734510407e-4
+y[i]*(-0.2073370639e-5+y[i]*0.2093387211e-6)));
ans2[i]=-0.1562499995e-1+y[i]*(0.1430488765e-3
+y[i]*(-0.6911147651e-5+y[i]*(0.7621095161e-6
-y[i]*0.934945152e-7)));
j0[i]=sqrt(0.636619772/ax[i])*(cos(xx[i])*ans1[i]-z[i]*sin(xx[i])*ans2[i]);
}
}
}
I later called the function above with:
bessj0(p,j0);
But I'm not sure if a certain line in the implementing code, to return Ip[] would be valid, viz:
void Integrals(double Ip[20])
{
double alpha[20],beta[20];
for (int t=0;t<20;t++)
{
double j0[20],j1[20],H0[20],H1[20],p[20];
void bessj0(double x[20],double j0[20]);
void bessj1(double x[20],double j1[20]);
alpha[t] = beta[t] = 2*t*PI;
p[t] = 2*sqrt(pow(alpha[t],2.0)+pow(beta[t],2.0));
bessj0(p,j0);
bessj1(p,j1);
H0[t] = sum0(p[t]);
H1[t] = sum1(p[t]);
Ip[t] = ((PI*p[t])/2) * ((2*p[t]*j0[t]) + (((PI*p[t])/2) * ((H0[t]*j1[t])-(H1[t]*j0[t]))) - j1[t]);
}
}
Also, why didn't I get an error at line (***)? The function is defined thus:
double sum0(double x)
{
double H0;
H0 = x - (pow(x,3)/9) + (pow(x,5)/(9*25)) - (pow(x,7)/(9*25*49))
+ (pow(x,9)/(9*25*49*81)) - (pow(x,11)/(9*25*49*81*121));
return H0;
}
The code pasted compiles without any errors. But I'm concerned to make sure I'm doing the correct and logical thing in the 1st place.
I'd be greatful for constructive criticism and useful tips directly applicable to the pasted code. Thanks a lot!
|
|
|
|
|
If you are going to pass arrays then it is best to pass them as a pointer to array.
void Integrals(double Ip[20])
{
....
for( i=0; i<20; ++i )
Ip[i] = what ever;
}
void Integrals(double *Ip)
{
....
for( i=0; i<20; ++i )
Ip[i] = what ever;
}
void Integrals(double *Ip, int nSize)
{
....
for( i=0; i<nSize; ++i )
Ip[i] = what ever;
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi,
I've got a problem with the IShellFolder2 interface...
I want to use its GetDetailsEx funtion in a file tree application...
I add an interface pointer to my class and add a relese funtion for it in the destructor.
But when i compile the code VC++ gives me the following errors:
h:\Mydoc\C++\Visual Studio Projects\Lars\TreeNode.cpp(11) : error C2027: use of undefined type 'IShellFolder2'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ShObjIdl.h(83) : see declaration of 'IShellFolder2'
h:\Mydoc\C++\Visual Studio Projects\Lars\TreeNode.cpp(11) : error C2227: left of '->Release' must point to class/struct/union
I've tried to move the code into a seperate file but still gets the same error..
I've no idea what can be wrong... Do I have to import something that implement the interface?
Thanks....
|
|
|
|
|
Try adding the following lines at the top of your stdafx.h file:
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#define _WIN32_IE 0x0600 These ensure that when the Windows headers get compiled, the features that are only present in later versions of Windows (or provided by Internet Explorer) are available.
Gurra_Koo wrote:
Do I have to import something that implement the interface?
No. It sounds like in your application you're getting the interface from an API call (most likely SHGetDesktopFolder() ). The only time you would implement IShellFolder2 would be if you were writing a namespace extension for an object that would become part of the Windows shell.
Software Zen: delete this;
|
|
|
|
|
Thanks... That really helped!
|
|
|
|
|
From my MFC program how can i find out the drive letter from which the OS Booted
Also
how to convert "\Device\HarddiskVolume1\" to "c:\"
any help/suggestion
is most welcome
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
That's easy. Have a look at the WinObj tool from http://www.sysinternals.com/[^].
You will find the information in the Windows NT namespace (Path "??").
Enumerate the namespace using the native API and search for the Harddisk aliases.
Don't try it, just do it!
|
|
|
|
|
|
WM_GETMINMAXINFO
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Hi all,
In my application using eVC++ 4.0, I have to draw ellipses with different line styles such as dashed, dotted,
dashed-dotted..
I do it in VC++ 6.0, using Bezier Functions...
But some of the functions are not supported in eVC++ 4.0.
Is there any way to draw these ellipses?
Please help me...
Thanks in Advance,
Arun AC
|
|
|
|
|
As MSDN state,
The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.
I am facing Problem in this?i just want to transfer data back from the SendMessage,The way The ListView and etc work.
here is my code listing
on_click()<br />
{<br />
char nam1[255];<br />
nam1[0]=NULL;<br />
this->UpdateData(FALSE);<br />
::SendMessage((HWND)this->m_lHandle,WM_USER+90,0,(LPARAM)&nam1);<br />
<br />
MessageBox(nam1);<br />
}
and message Handlling
on_message()<br />
{<br />
char *nam1=(char*)lParam;<br />
<br />
char Text[100];<br />
sprintf(Text,"%u",nam1);<br />
::MessageBox(NULL,Text,"address of Nam1",MB_OK);<br />
strcpy(nam1,"codeproject");<br />
::MessageBox(NULL,Text,"kola",MB_OK);<br />
<br />
}
Both of Code working Fine, but name Variable contain some garbage value insist of codeproject
Any help is greatly apreciated
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
You are getting your levels of indirection mixed up.
ThatsAlok wrote:
char nam1[255];
Ok, nam1 is an array of 255 chars, can be accessed as a char*
ThatsAlok wrote:
(LPARAM)&nam1
You are passing the address of nam1, or a char**. You should drop the &.
ThatsAlok wrote:
char *nam1=(char*)lParam;
you are casting a char** to a char*, here is your error
ThatsAlok wrote:
strcpy(nam1,"codeproject");
You end up copying "codeproject" to the address of your string pointer, not the string as you expected.
To see this happen, open up the memory window in VC while you debug your code. watch the memory at mem1 and at the address of mem1.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Really i am doing very big Pointer Mistake,i am still not able to sort out my problem.
something is missing that i need.
PJ Arends wrote:
ThatsAlok wrote:
char *nam1=(char*)lParam;
you are casting a char** to a char*, here is your error
Here i don't understand what to do??
really i am feeling weak at pointer
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
|
i ma goin to lost my Mind if i don't complete this.
the Mentle Wagon is standing outside to send me remand home.if i am not able to transfer the String though send message and get it back.
please please help me . give me right pointer or line,two line of code please
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
PJ Arends wrote:
ThatsAlok wrote:
char *nam1=(char*)lParam;
you are casting a char** to a char*, here is your error
actually i am facing problem in this step,i can successfully passing integer value by address but problem is when everi try to change the value of that interger, my MSStudio fails.
ie little code here
sending code
int *ji=new int;<br />
*ji=10;<br />
::SendMessage((HWND)this->m_lHandle,WM_USER+90,0,(LPARAM)*ji);<br />
CString s;<br />
s.Format("%d",*ji);<br />
MessageBox(s);
Receiving Code
int * i=(int*)lParam;<br />
char Text[100];<br />
sprintf(Text,"%d ",*i);<br />
::MessageBox(NULL,Text,Text,MB_OK);<br />
<br />
*i=40;
hope any body understand my problem.
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
ThatsAlok wrote:
::SendMessage((HWND)this->m_lHandle,WM_USER+90,0,(LPARAM)*ji);
ThatsAlok wrote:
int * i=(int*)lParam;
You have to fix one of these two lines. In the SendMessage line you are passing 10 (*ji, the value that ji points to) as the lparam. Then in the recieving function you are casting the 10 to an int pointer. So basicly you are telling the program that the integer you want to work with is stored at memory address 10. This most likely gives you an access violation.
In the following code, you will notice that ji is already a pointer (int *ji), so when we send it via SendMessage we do not try to deference it ((LPARAM)*ji) which ends up passing the value 10, nor do we take the address of it ((LPARAM)&ji) which is actually passing a pointer to a pointer to an int (int **).
int *ji = new int;
*ji = 10;
::SendMessage((HWND)this->m_lHandle,WM_USER+90,(LPARAM)ji);
...
int *i = (int *)lParam If you have trouble with pointers read those two excellent articles I pointed you to earlier.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|