W8030 warning message

closed account (Shp21hU5)
Hi Guy's can you help!

I've modified a delphi code to C++ [ find Radius and Center Point from three coordinates ] but get W8030 warning meesage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  bool result = false;
  long double x = 0.0, y = 0.0;
  long double ma = 0.0, mb = 0.0;
  result = true;
  if ( samepoint( p1, p2 ) || samepoint( p1, p3 ) || samepoint( p2, p3 ) || ( ( p1.x == p2.x ) && ( p1.x == p3.x ) ) )
  {
    result = false;
    return result;
  }

  /*we don't want infinite slopes,
   (or 0 slope for line 1, since we'll divide by "ma" below)*/
  if ( ( p1.x == p2.x ) || ( p1.y == p2.y ) )
    swap( p2, p3 );
  if ( p2.x == p3.x )
    swap( p1, p2 );
  if ( p1.x != p2.x )
    ma = double( ( p2.y - p1.y ) ) / ( p2.x - p1.x );
  else
    ma = 1e6; /*result:=false;*/
  if ( p2.x != p3.x )
    mb = double( ( p3.y - p2.y ) ) / ( p3.x - p2.x );
  else
    mb = 1e6; /*result:=false;*/
  if ( ( ma == 0 ) && ( mb == 0 ) )
    result = false;
  if ( result == true )
  {
    x = double( ( ma * mb * ( p1.y - p3.y ) + mb * ( p1.x + p2.x ) - ma * ( p2.x + p3.x ) ) ) / ( 2 * ( mb - ma ) );
    if ( ma != 0 )
      y = double( - ( x - double( ( p1.x + p2.x ) ) / 2 ) ) / ma + double( ( p1.y + p2.y ) ) / 2;
    else
      y = double( - ( x - double( ( p2.x + p3.x ) ) / 2 ) ) / mb + double( ( p2.y + p3.y ) ) / 2;
    center.x = ( x );
    center.y = ( y );

    X__Centre = ( center.x );
    Y__Centre = ( center.y );
  }
  return result;
I don't have delphi.

What is the text associated with W8030?
What line does it point to?
What does the definition of this function look like?
Last edited on
What is the actual text of the warning message please.
On which line (or lines) does the message occur?
closed account (Shp21hU5)
Hi Guys
Thanks for you quick response I enclose the warning messages which are generated and point to the 'swap()' function. even though the warning messages are generated the coding works fine.

[C++ Warning] Mill_Calc.cpp(757): W8030 Temporary used for parameter 'p1' in call to 'TMill_Calculator::swap(TMill_Calculator::TRealPoint &,TMill_Calculator::TRealPoint &)'
[C++ Warning] Mill_Calc.cpp(757): W8030 Temporary used for parameter 'p2' in call to 'TMill_Calculator::swap(TMill_Calculator::TRealPoint &,TMill_Calculator::TRealPoint &)'
[C++ Warning] Mill_Calc.cpp(759): W8030 Temporary used for parameter 'p1' in call to 'TMill_Calculator::swap(TMill_Calculator::TRealPoint &,TMill_Calculator::TRealPoint &)'
[C++ Warning] Mill_Calc.cpp(759): W8030 Temporary used for parameter 'p2' in call to 'TMill_Calculator::swap(TMill_Calculator::TRealPoint &,TMill_Calculator::TRealPoint &)'
Where are p1 and p2 declared, what are their types?

The message seems to imply that rather than passing the parameters to swap by reference, instead a temporary variable is created and passed instead.

As well as trying to understand what the message means, perhaps the key question is, does the swap() function actually work here, or does it leave the two arguments unaltered afterwards?
closed account (Shp21hU5)
Hi Chervil

Thank you for your help, your right the swap() function doesn't actually right. I've since bypassed the swap() function with a manual piece of code which does the job and eliminates the warning messages but now the program crashes so I think its back to the drawing board for me.

Thank you for all your help.
Topic archived. No new replies allowed.