Results 1 to 7 of 7

Thread: [RESOLVED] Why do i get this warning?

Threaded View

  1. #1

    Thread Starter
    Addicted Member cc2^^'s Avatar
    Join Date
    Apr 2008
    Location
    Right behind you.
    Posts
    165

    Resolved [RESOLVED] Why do i get this warning?

    I have created a DLL in C++ that contains a function which a program made in VB6 will use.
    But i get the Overflow error when running the app.
    I know for sure it is the function in the DLL that causes this.

    Here is the function:

    Code:
    void __stdcall DLL_EXPORT CalculateGravity(double *X1,double *Y1,double *X2,double *Y2,double *FX1,double *FY1,double *FX2,double *FY2,double *W1,double *W2,double MaxAttraction,double MaxMovement,boolean AffectOnlyOne)
    {
    double dx;
    double dy;
    double d1;
    double d2;
    double F1;
    double F2;
    double TempX;
    double TempY;
    double D;
    
    if (AffectOnlyOne)  //Only Particle 1 Moves
    {
    
       dx == *X1 - *X2;
       dy == *Y1 - *Y2;
       d1 == (dx * dx) + (dy * dy);
       if (d1 == 0) {d1 = 0.00001;}
       F1 == *W2 / (d1 * sqrt(d1));
       if (F1 > MaxAttraction) {F1 == MaxAttraction;}
       TempX == *FX1 - (F1 * dx);
       TempY == *FY1 - (F1 * dy);
       D == sqrt((abs(TempX) * abs(TempX)) + (abs(TempY) * abs(TempY))); //When i remove this line of code here, the Overflow error stops occuring.
       if (D > MaxMovement) {
       D == D / MaxMovement;
       TempX == TempX / D;
       TempY == TempY / D;
       }
       *FX1 = TempX;
       *FY1 = TempY;
    
    }
    else  //Both Particle 1 and Particle 2 Moves
    {
    //not done with this part yet
    
    }
    }
    And it gets called from the VB6 app like this:

    Code:
    'Simulating the particles around the galaxy
    For i = 1 To UBound(P) - 1
       CalculateGravity P(i).X(CurrentFrame), P(i).Y(CurrentFrame), P(0).X(CurrentFrame), P(0).Y(CurrentFrame), P(i).fx, P(i).fy, P(0).fx, P(0).fy, P(i).W, P(0).W, MaxAttraction, MaxMovement, True
       ReDim Preserve P(i).X(MaxProcessFrame + 1)
       ReDim Preserve P(i).Y(MaxProcessFrame + 1)
       P(i).X(CurrentFrame + 1) = P(i).X(CurrentFrame) + P(i).fx
       P(i).Y(CurrentFrame + 1) = P(i).Y(CurrentFrame) + P(i).fy
    Next
    Basically what this function does is it calculates a bunch of stuff and then overwrites the result on two variables (FX1 and FY1). Those two variables is stored on the VB6 app that calls the function.

    Also when i compile the DLL i get alot of warnings saying "Statement has no effect" on almost every line of code.

    I'm new to C++, so excuse me if i'm missing something obvious here.

    If anyone knows why i get those warnings and the Overflow error please let me know. Thanks.
    Last edited by cc2^^; Jun 17th, 2011 at 09:23 AM.
    I think I am, therefore, I am. I think.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width