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
 1549: change signature vs. inline
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Apr 05 2007 :  08:13:57 AM  Show Profile  Reply with Quote
VAX 1549, VS2005 SP1, WinXP SP2, Unmanaged C++

in cpp:
inline void cTest::TestFunction(void)
{
    // some code
}

in header:
class cTest {
    // ...
    void TestFunction(void);
    // ...
};


If I use Change Signature on TestFunction (in cpp), then the inline will disappear.
If I know correctly, it is enough to put "inline" into the cpp.

Mike from reFX
Junior Member

24 Posts

Posted - Apr 05 2007 :  09:06:03 AM  Show Profile  Reply with Quote
VAX is correct. The inline doesn't work in this case. It only works when it's directly within the class definition (in the .h file) like this:

class CTest {
    inline void TestFunction (void)
    {
        // do something
    }
};

Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Apr 05 2007 :  09:40:02 AM  Show Profile  Reply with Quote
No. You are using implicit inline. Inline keyword is not neccessary in your case at all.
see http://msdn2.microsoft.com/en-us/library/z8y1yy88(VS.71).aspx
and example 1.

I've copied the following code from msdn (http://msdn2.microsoft.com/en-us/library/bw1hbe6y(VS.71).aspx)

// Inline_Member_Functions.cpp
class Account
{
public:
    Account(double initial_balance) { balance = initial_balance; }
    double GetBalance();
    double Deposit( double Amount );
    double Withdraw( double Amount );
private:
    double balance;
};

inline double Account::GetBalance()
{
    return balance;
}

inline double Account::Deposit( double Amount )
{
    return ( balance += Amount );
}

inline double Account::Withdraw( double Amount )
{
    return ( balance -= Amount );
}
int main()
{
}

As you can see, inline should be placed before definition and not before declaration.

Edited by - accord on Apr 05 2007 09:40:54 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Apr 05 2007 :  1:51:39 PM  Show Profile  Reply with Quote
I have seen some discussion about inline, and what the compiler will and will not do on this forum before. Personally I am taking the very simple approach - the code compiles, so VA should not remove "inline"

case=5857

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

bugfix
Tomato Guru

Germany
324 Posts

Posted - Apr 05 2007 :  1:53:02 PM  Show Profile  Reply with Quote
either usage is of inline is fine.

mike: your usage is just useless though, if the function definition is inside of class its automatically inline!

http://www.mf-sd.de

Edited by - bugfix on Apr 05 2007 1:55:07 PM
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Apr 05 2007 :  2:08:49 PM  Show Profile  Reply with Quote
> I have seen some discussion about inline,
> and what the compiler will and will not do on this forum before.

I think Microsoft's "C++ Language Reference" can be a reference for a Microsoft Visual Studio plugin (VAX). What do you think? (my example is from there)

Edited by - accord on Apr 05 2007 2:13:41 PM
Go to Top of Page

bugfix
Tomato Guru

Germany
324 Posts

Posted - Apr 05 2007 :  2:11:24 PM  Show Profile  Reply with Quote
C++STANDARD-ISOIEC14882
thats THE standard and nothing else:)

http://www.mf-sd.de
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Apr 05 2007 :  2:16:42 PM  Show Profile  Reply with Quote
quote:
Originally posted by bugfix

C++STANDARD-ISOIEC14882
thats THE standard and nothing else:)



Yes, this is the standard, but in my opinion VAX is based on a Microsoft product, so should adapt to Microsoft's implementation.
By the way can you tell me what this ISO says about inline? (Probably the same as MS's reference in this case)

Edited by - accord on Apr 05 2007 2:24:00 PM
Go to Top of Page

bugfix
Tomato Guru

Germany
324 Posts

Posted - Apr 05 2007 :  2:24:32 PM  Show Profile  Reply with Quote
sorry.. but thats just BS. ever heard of cross platform development?
i already said. either is fine, inline can be used for function declarations and definitions.

http://www.mf-sd.de
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Apr 05 2007 :  2:41:51 PM  Show Profile  Reply with Quote
OK, I was not exact.
If you do cross-platform development, you should adapt to Microsoft's AND other compilers at the same time (for example to GCC)
If there is significant different in a language feature between MS and GCC, you won't use this feature at all, but VAX can use.
Hopefully usually there is a solution that right for MS's compiler and other compilers also, and VAX should generate general code in these cases.

Edited by - accord on Apr 05 2007 2:42:53 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Apr 05 2007 :  4:10:44 PM  Show Profile  Reply with Quote
I used to do cross platform development, targeting both UNIX and Windows via the C++ Qt library. This library uses Signals and Slots, via macro's and its own pre-processor, so it is "extending" the C++ language its self, via official C++ mechanisms (macros)

I used VAX all the time on this code base, as do other developers, and there is a FAQ about Qt. Making VAX work in the "real world" is important, what ever "real world" happens to mean. This is simply me being practical, since our customers want VAX to "just work"

Turning to the question of standards, there are all sorts of things in C++ that VAX does NOT handle 100% correctly. Nasty template code or complex macro's are the main source of these problems. Remember people want VAX to parse code in real time. They do not ask compilers to compile in real time. Plus we need to handle code as you are typing it - so it would never actually compile.

Where VAX diverges from the ISO standard, the Microsoft compiler, or some other "standard", e.g. a perfectly valid Qt class using signals and slots I view this as a bug to be addressed, since it is causing our customers problems. What their compiler of choice makes of the code... That I leave up to them.

Hopefully this helps a little bit.

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

Mike from reFX
Junior Member

24 Posts

Posted - Apr 07 2007 :  08:34:10 AM  Show Profile  Reply with Quote
Sorry, I'm doing cross platform development too and thus I don't always follow "Microsofts" way of doing things. Declaring methods inline outside the class declaration does not work for GCC 4.x (using it on OSX) etc.
Go to Top of Page

bugfix
Tomato Guru

Germany
324 Posts

Posted - Apr 07 2007 :  09:43:32 AM  Show Profile  Reply with Quote
quote:
Originally posted by Mike from reFX

Sorry, I'm doing cross platform development too and thus I don't always follow "Microsofts" way of doing things. Declaring methods inline outside the class declaration does not work for GCC 4.x (using it on OSX) etc.


huh? if that would be true you couldn't use e.g. boost on mac osx.

http://www.mf-sd.de
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