Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Multiline preprocessor definitions corrupt parser
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gadibergman
New Member

Israel
9 Posts

Posted - Jul 12 2007 :  06:23:35 AM  Show Profile  Reply with Quote
When using multiline preprocessor definitions such as the one below, the parser fails and reports mistakes in all code which comes later in the page.

#define CHECK_SOCK_ERROR( variable ) \if ( variable == SOCKET_ERROR ) \{\ m_iLastError = WSAGetLastError();\ return false;\}

The workaround is to define the whole of it in one line, but frequently the definition is long so it becomes unreadable when placed in one line of code.


feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 12 2007 :  07:20:20 AM  Show Profile  Reply with Quote
Which IDE and version of VA are you using?
I have just copy / pasted this into the top of a cpp file, using VS2005 and VA 1559 and I am not seeing any problems. I added an invalid symbol, just to make sure that VA would underline this symbol, and only this symbol, and this worked correctly.

Is this single #define on its own enough to cause problems for you?
I am wondering if somehow it is interacting with a header file, or another #define to trigger this problem.

zen is the art of being at one with the two'ness
Go to Top of Page

gadibergman
New Member

Israel
9 Posts

Posted - Jul 12 2007 :  07:54:42 AM  Show Profile  Reply with Quote
I am using VS2005 and VA 1559 too. This is not a new bug, I believe it can be found in several release versions.

The first symbol marked as a mistake is m_iLastError inside the macro definition although it is not a mistake.
At first it may seem fine, but after you compile the code and role the page down and up, you'll see the entire content of the page from the macro downwards fill with errors.

Here is a part of the header file:
class CReliableConnection : public IConnection
{
SOCKET m_iSocket;
int m_iLastError;
...

Here is some code from the source file below the macro:
bool CReliableConnection::Connect( const char* szAddress, int iPortNumber )
{
SafeCloseSocket();

m_iSocket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
CHECK_SOCK_ERROR( m_iSocket );

sockaddr_in clientService;

clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr( szAddress );
...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 12 2007 :  08:17:57 AM  Show Profile  Reply with Quote
When you first load the IDE and open a file VA will not attempt to underline anything as a mistyped symbol. This is an optimisation, to avoid underlining in files that you are not actually editing.

Can you try a quick test for me please?
If you reload the IDE, open the cpp file and then add the line:

banana = 2;


to the first function after the macro what happens? Obviously banana should be underlined as a mistyped symbol, and adding this line of code to the file should trigger VA's underlining of mistyped symbols.

From your description I am expecting you to see "everything" underlined as a mistyped symbol.

So far I have not been able to reproduce the problem here using the bits of code you posted, but this does not prove much. Clearly you are having a problem, and we need to find out why.

zen is the art of being at one with the two'ness
Go to Top of Page

gadibergman
New Member

Israel
9 Posts

Posted - Jul 12 2007 :  08:44:38 AM  Show Profile  Reply with Quote
When I reload the IDE and open the cpp, nothing is underlined.
Then, when I add that line, ONLY 'banana' is marked as a mistyped symbol.
After that, when I roll the page up and down using the wheel of the mouse, all other symbols below the macro also become marked as mistyped symbols.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 12 2007 :  11:48:10 AM  Show Profile  Reply with Quote
I was not expecting that result.
When you say "all other symbols" does this include the names of functions declared in this cpp file?
Does VA's alt-m list work correctly?

Do you have the time to create a new, default C++ project, and then copy the problem cpp and header files into this project? I am wondering if you will see the same problems here. If so then the effect is localised to just these two files, and possibly something in your stable include directory list.

Can you please go to:

VA Options -> About -> Copy Info

and paste the details (from the clipboard) into this thread. This will give us the basic information about your setup.

zen is the art of being at one with the two'ness
Go to Top of Page

kevinsikes
Tomato Guru

USA
271 Posts

Posted - Jul 12 2007 :  3:35:17 PM  Show Profile  Reply with Quote
Does the carriage return immediately follow the \\ character in your multiline macro as required? I see the behavior you report when I insert a space after the backslash. In this case, the code fails to compile.

If that's not the case, by any chance is your environment configured to use Unix line endings?

Kevin Sikes
Infotainment Platform Design Engineer
Ford Motor Company
Go to Top of Page

gadibergman
New Member

Israel
9 Posts

Posted - Jul 13 2007 :  03:26:08 AM  Show Profile  Reply with Quote
Feline, I will get back to you early next week.

Kevin, the carriage return immediately follows the \\ character as required and the code compiles successfully.
I do not think that my environment is configured to use Unix line endings. I don't even know how to do it and I set the environment myself with everything mostly default.

Note that these symbol errors sometimes take 3-4 page scrolls for them to appear. It would seem to me as a programmer that you have threads that calculate where to display error marks and sometimes some threads collide because the scroll is quick, and I have a dual-core processor (Core-2-Duo). Could that be the case?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 13 2007 :  07:11:51 AM  Show Profile  Reply with Quote
Something is triggering the underlining, but what puzzles me is the delay. "banana" was underlined very promptly, but the rest of the code was only underlined after a while.

It is almost as if VA has to parse something else, beyond the current file - perhaps the matching header file, before it decides to underline all symbols.

gadibergman we may need to ask for a stripped down copy of the two files to try and reproduce this internally. This assumes the two files on their own are enough to reproduce the problem. If they are I suspect you could delete the bodies out of all of the function implementations, and probably quite a bit more code, and still see the problem. Hopefully you will be able to strip the files down to the point where you feel able to send us a copy for testing purposes.

zen is the art of being at one with the two'ness
Go to Top of Page

gadibergman
New Member

Israel
9 Posts

Posted - Jul 15 2007 :  01:39:46 AM  Show Profile  Reply with Quote
VA Options:

VA_X.dll file version 10.3.1559.0 built 2007.07.06
Licensed to:
VA X: jacob at infodraw.com (1-user license) Support ends 2008.07.11
VAOpsWin.dll version 1.3.2.4
VATE.dll version 1.0.5.8
DevEnv.exe version 8.0.50727.762
msenv.dll version 8.0.50727.762
Font: Courier New 13(Pixels)
Comctl32.dll version 6.0.2900.2982
Windows XP 5.1 Build 2600 Service Pack 2
2 processors

Platform: Win32
Stable Includes:
E:\\Program Files\\Microsoft Visual Studio 8\\VC\\include;
E:\\Program Files\\Microsoft Visual Studio 8\\VC\\atlmfc\\include;
E:\\Program Files\\Microsoft Visual Studio 8\\VC\\PlatformSDK\\include;
E:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\include;

Library Includes:
E:\\Program Files\\Microsoft Visual Studio 8\\VC\\atlmfc\\src\\mfc;
E:\\Program Files\\Microsoft Visual Studio 8\\VC\\atlmfc\\src\\mfcm;
E:\\Program Files\\Microsoft Visual Studio 8\\VC\\atlmfc\\src\\atl;
E:\\Program Files\\Microsoft Visual Studio 8\\VC\\crt\\src;

Other Includes:


Edited by - gadibergman on Jul 15 2007 01:40:46 AM
Go to Top of Page

gadibergman
New Member

Israel
9 Posts

Posted - Jul 15 2007 :  01:49:59 AM  Show Profile  Reply with Quote
The following example code reproduces the bug on my machine, no additional header files required. The code compiles successfully, but VA reports symbol errors starting from "x1 = x2; ..." inside the macro definition. The first symbol marked as error is x1.

// Fibomacro.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <tchar.h>

void Fibonachi()
{
int a = 1, b = 1, i;
printf( "%d, %d, ", a, b );

for ( i = 0; i < 100; ++i )
{
int c = a + b;
printf( "%d, ", c );
a = b; b = c;
}
}

#define MULTILINE_MACRO(x1,x2,x3) \ for ( i = 0; i < 100; ++i )\{\ int x3 = x1 + x2;\ printf( "%d, ", x3 );\ x1 = x2; x2 = x3;\}


void Fibomacro()
{
int a = 1, b = 1, i;
printf( "%d, %d, ", a, b );
MULTILINE_MACRO(a,b,c);
}

int _tmain(int argc, _TCHAR* argv[])
{
//Fibonachi();
Fibomacro();
return 0;
}

Go to Top of Page

gadibergman
New Member

Israel
9 Posts

Posted - Jul 15 2007 :  01:57:48 AM  Show Profile  Reply with Quote
As specified above, the required steps to take for seeing the symbol errors are:
1. Editing the file.
2. Scrolling the page up and down using the mouse.
Go to Top of Page

kevinsikes
Tomato Guru

USA
271 Posts

Posted - Jul 15 2007 :  9:04:35 PM  Show Profile  Reply with Quote
gadibergman,

Thank you for your code sample. I reproduced this issue on my machine twice out of 100+ attempts by editing, then scrolling wildly until the behavior appeared. However, it immediately corrected itself when I began typing again. The intermittent nature of the problem does seem to point to a parser thread timing issue. My suspicion with your most recent code sample is that the parser is confused because you specified x3 as a formal macro parameter, then inside the macro you define x3 as an int. While this is legal, it may confuse our parser. However, this does not explain why the issue would have been triggered by your original multiline macro, which contains no such ambiguity. I'm guessing you're seeing this behavior more than 2% of the time? Does the problem go away when you start typing again, only to come back when you scroll with the mouse?

Kevin Sikes
Infotainment Platform Design Engineer
Ford Motor Company
Go to Top of Page

gadibergman
New Member

Israel
9 Posts

Posted - Jul 16 2007 :  04:58:01 AM  Show Profile  Reply with Quote
Kevin,

Yes, when I start typing the problem seems to go away and it comes back when scrolling. I see this behavior more than 30% of the time.

Gadi
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 17 2007 :  07:42:52 AM  Show Profile  Reply with Quote
How often are you seeing this problem in your main code? Is it about 30% of the time? All of the time? Some other number?

In your main code, does making a further edit remove all of this extra underlining, or does it remain?

I am wondering how similar the behaviour with the simplified example is to your main code. You are seeing this a lot more than Kevin is, but so far I have no idea why. There is nothing obviously different, or odd, in your VA about information.

As an experiment I have just tried this test here, on a single processor test machine, and in 5 tests I have seen the problem 3 times!

One interesting fact is that I resized my VS2005 window, so that only 23 lines of code were visible at a time. I did this to make sure there was plenty of scope for scrolling the code with the mouse.

gadibergman and Kevin, how much room did you have for code scrolling? This might be one of the key factors at work here, scrolling the code that VA gets confused by completely off the screen and then back on again may be the key trigger.

case=7732

zen is the art of being at one with the two'ness
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 17 2007 :  07:51:43 AM  Show Profile  Reply with Quote
I have just tried using VA's stdafx.h file to work around this problem, but unfortunately it does not help.

Does this effect all files? Or only files with multi-line macro's in them?
If it only effects some files could you move the macro's to header files? I am looking for a temporary work around that is easier than making the macro's single line, which as you say makes them hard to read.

zen is the art of being at one with the two'ness
Go to Top of Page

gadibergman
New Member

Israel
9 Posts

Posted - Jul 17 2007 :  3:40:42 PM  Show Profile  Reply with Quote
I see this problem only in files that have multi-line macros and files that include (header) files with multi-line macros. 30% of the time only applies to these files with multi-line macros.

Go to Top of Page

kevinsikes
Tomato Guru

USA
271 Posts

Posted - Jul 17 2007 :  7:36:40 PM  Show Profile  Reply with Quote
I tried resizing my code window to various heights, but never got it to reproduce more than 2% of the time.

Kevin Sikes
Infotainment Platform Design Engineer
Ford Motor Company
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 18 2007 :  07:07:18 AM  Show Profile  Reply with Quote
I am seeing something quite different to Kevin, which suggests there is some other factor at work here, but off hand I have no idea what that might be.

Hopefully our developers will be able to reproduce this.

zen is the art of being at one with the two'ness
Go to Top of Page

mmb
Senior Member

42 Posts

Posted - Jul 24 2007 :  08:06:03 AM  Show Profile  Reply with Quote
I seen this problem quite often on my machine, but was not able to correlate it to multi-line defines. As my main machine is still a PIII 700 this does not seems to be a multi-processor problem. Moreover, it happens on my VMWARE running on a 2.4GHz Ahthlon also, so it might not be a problem with speed.
I can reproduce it every time with one source file of our library by using the following steps:
1.) Load the problematic file. All fine yet.
2.) Press the reparse button
3.) Scroll using PAGE-DOWN/PAGE-UP above the first function behind the multiline-define and back.

However I was not able to isolate it to a smaller test case yet, when I just copy the "problematic" code into an empty project it works...

I'm using VC6 + 1557 on the VMWARE and VS2005 + 1559 on the PIII ...

Hope that helps. As our library is GPL I can provide the whole project for further testing ...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 24 2007 :  09:57:06 AM  Show Profile  Reply with Quote
That is interesting. I wonder if included header files are a factor.

If the project is "small" I would certainly be interested in seeing it, and trying to reproduce this here. "small" is tricky to define, but if this is 200meg of source code that would qualify as large

zen is the art of being at one with the two'ness
Go to Top of Page

mmb
Senior Member

42 Posts

Posted - Jul 25 2007 :  09:12:36 AM  Show Profile  Reply with Quote
feline: The source code is above 1.5M bzip2, so middle sized I would say. But the problem is always in one file, it might be possible to remove some. I havn't tested it yet (sorryly there are more than hundred source files ;-)
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 25 2007 :  2:25:30 PM  Show Profile  Reply with Quote
That's a fair number of source files, and clearly would take a little working through.

If you can submit the zip file and details of the file to look at via the form:

http://www.wholetomato.com/support/contact.asp

including this thread ID or URL in the description, so we can match it up, I will have a look, see if I can reproduce this bug, and also trim down the number of files a little.

zen is the art of being at one with the two'ness
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 30 2007 :  09:09:45 AM  Show Profile  Reply with Quote
I have the test code, thank you for this, and I have replied via email. The bug report is:

case=7732

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000