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
 VAX - Problems returning references to arrays
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

steve.thresher
New Member

United Kingdom
8 Posts

Posted - Dec 23 2004 :  08:47:26 AM  Show Profile
I'm using VAX with VS.NET 2003 and it refuses to recognise the get_text_ref() function in the following class:

<code>
class CTest
{
private:
char m_text[10];

public:
CTest(const char (&text)[10])
{
memcpy(m_text,text,sizeof(text));
}

const char (&(get_text_ref)(void) const)[10]
{
return(m_text);
}

const char *get_text_ptr(void)
{
return(m_text);
}
};
</code>

If I attempt to use the class as follows:

<code>
char text[10]={'A','B','C','D','E','F','G','H','I','J'};

CTest test_object(text);

char output[11]={0};
memcpy(output,test_object.get_text_ref(),sizeof(test_object.get_text_ref()));

printf(output);
</code>

The code compiles OK and does what I expect (output the 10 characters A-J) but VAX refuses to list the get_text_ref() function after pressing the '.' character at the end of test_object. All I get listed are the member variable, constructor and get_text_ptr() member function.

Can anyone suggest what the problem is? I have included the VAX version information below if that makes any difference.

VA_X.dll file version 10.1.1287.0
Licensed to:
VA X: conrad at systemsaxis.co.uk (8-user license) Support ends 2005.10.07
VA.NET 7.1:
VAOpsWin.dll version 1.2.0.4
DevEnv.exe version 7.10.3077.0
msenv.dll version 7.10.3077.0
Font: Courier New 11(Pixels)
Comctl32.dll version 5.82.2900.2180
WindowsNT 5.1 Build 2600 Service Pack 2
Single processor

Platform: Custom
Stable Includes:
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\ATLMFC\\INCLUDE;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\INCLUDE;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\PlatformSDK\\include\\prerelease;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\PlatformSDK\\include;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\SDK\\v1.1\\include;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\SDK\\v1.1\\include;
c:\\axis\\bin;
c:\\axis\\include;

Library Includes:

Other Includes:


feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Dec 23 2004 :  4:19:03 PM  Show Profile
coping your code into a C++ header file i am seeing:



here i have told VAX to colour function names orange. as you can see "get_text_ref" is not being coloured as a function. it seems that VAX does not understand this bit of code, so it is not detecting this function.

to be fair, i know how VAX feels about this! i don't really understand this code either.

case=477

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

steve.thresher
New Member

United Kingdom
8 Posts

Posted - Dec 24 2004 :  06:57:11 AM  Show Profile
The code compiles fine using both VS.NET 2003 (compiler level 4) and Borland 5.5 command line tools. Does the following make the code any easier to follow?

Variable that is a reference to a ten character array

char (&var)[10]


Function returning a reference to a 10 character array

char ((&fn)(void))[10]


Function returning a const reference to a 10 character array

const char ((&fn)(void))[10]


Member function returning a const reference to a 10 character array that doesn't modify member variables.

const char ((&CTest::fn)(void) const)[10]

Go to Top of Page

rblondeau
Tomato Guru

Canada
102 Posts

Posted - Dec 25 2004 :  01:12:30 AM  Show Profile
Although I do not doubt that all of the above examples work, I would have to say that the fact that I have never seen this technique described before would indicate that it is not something that is very commonly done. It is most likely for this reason that VAX does not handle it correctly.

That being said, it is nice to see something new (to me anyhow) that I can chew on.
Go to Top of Page

jpizzi
Tomato Guru

USA
642 Posts

Posted - Dec 27 2004 :  12:32:13 AM  Show Profile
Is this perhaps C# code? I put this into a C++ file in VS .NET 2003, and get
error C2090: function returns array


Joe Pizzi

Edited by - jpizzi on Dec 27 2004 12:32:48 AM
Go to Top of Page

steve.thresher
New Member

United Kingdom
8 Posts

Posted - Dec 27 2004 :  08:32:00 AM  Show Profile
It is not C# code
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Dec 29 2004 :  2:22:59 PM  Show Profile
quote:
Originally posted by steve.thresher

The code compiles fine using both VS.NET 2003 (compiler level 4) and Borland 5.5 command line tools. Does the following make the code any easier to follow?

Variable that is a reference to a ten character array

char (&var)[10]


my brain is trying to throw an exception at this point

i look at this, and i find myself thinking this is actually an array of 10 references to char. i think the basic problem is you are doing something with C++ the rest of us are not familiar with

it is worth remembering that the VAX parser can be called "good enough", it cannot do everything a compiler can, since it does not have the same luxury of constant files and all the time in the world that the compiler has.

quote:
Originally posted by jpizzi

Is this perhaps C# code? I put this into a C++ file in VS .NET 2003, and get: error C2090: function returns array


interesting, it compiles without any warnings or errors for me. i just copy and pasted the class into one of my header files, and .NET 2003 was quite happy. this is a fairly new project, mostly using the default settings for warnings, etc. i have turned RTI on though.

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

steve.thresher
New Member

United Kingdom
8 Posts

Posted - Dec 30 2004 :  04:30:07 AM  Show Profile
I know its unusual, most people would store strings with std::basic_string or CString rather than arrays of text but the code is correct. If you use the debugger with the test class from my original post and step into the constructor you will see the parameter passed is a reference to the array not an array of references.


I would like to mention at this point (before I sound too much like a moaning old git) that I do think VAX is an excellent product that has saved me a huge amount of time on looking up defines and function prototypes. I was the one who introduced the product to our other developers and nagged the boss to buy the licences

Edited by - steve.thresher on Dec 30 2004 04:43:24 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Dec 30 2004 :  4:31:29 PM  Show Profile
LOL good answer

well this is in the list of things for the WT developers to look at. however i cannot give you any time scale, since the list is rather long, and it keeps on growing. i think this has something to do with all the cases i keep on raising

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