Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Add Forward Declaration

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
TomJons Posted - Aug 06 2018 : 02:54:54 AM
Hey,

I tried to add forward declaration with reference and with pointer, for both I had this option disabled.

i.e.

void fun(T&, T*)
{...}

What conditions I must meet to use this VA functionality? I read the documentation and it works for pointers.. :)

Im looking forward for your response :)

Kind regards,
Tom
10   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Aug 11 2018 : 07:38:09 AM
This makes sense, I have put in a bug report for this:

case=118345
TomJons Posted - Aug 10 2018 : 07:03:18 AM
Ok, one more example: header file:
class A
{
public:
A(const Config& cfg)
: config_(cfg)
{}

private:
const Config& config_;
};

Add Forward declaration is:
- disabled from A constructor arg list (type name, member name)
- disabled from A constructor initializer list (type name, member name)
- enabled on member list - click at Config (type name)
- disabled on member list - click at config_ (member name)


Comparing to - Add Include - it does not matter if I click on type name, member name, where the cursor is.

Consider extending Add Forward Declaration functionality to above examples. :)

Kind regards,
Tom
TomJons Posted - Aug 10 2018 : 04:11:41 AM
Yes thank you

Kind regards,
Tom
feline Posted - Aug 09 2018 : 10:43:51 AM
I am seeing the same pattern and behaviour here. Thinking about it, there is a logic to this. If we assume you are placing function implementations into the cpp files, but only class / function declarations into header files, then adding a forward declaration into a cpp file does not make much sense, since you will simply end up with code that does not compile, since the forward declared symbol is not declared.

In contrast, in a header file, a forward declaration makes sense, and helps to minimize the number of #include lines added to your header files.

I know that inline functions in your header file break this pattern, but as we have seen VA is not offering to add a forward declaration to a function implementation.

Does this make sense and explain what is going on here?
TomJons Posted - Aug 09 2018 : 05:34:30 AM
I created new project and followed guide from your page: https://docs.wholetomato.com/default.asp?W823

my code is:

main.cpp:
class A
{
public:
GEdit* ptr_;


};

Header.h:
#pragma once
class GEdit {};


-----
Then I move cursor to GEdit class in main.cpp and still have Add Forward Declaration disabled. Note that Add Include is enabled. What's wrong?

Another example:
I added new header Header1.h

class B
{
public:
GEdit* ptr;
};

And then Add Forward Declaration works. Is it the only case when it works?

Kind regards
Tom
feline Posted - Aug 08 2018 : 10:41:59 AM
This is on the function implementation? I just want to check I understand correctly.

If so, then adding a forward declaration for type T won't help you, since the compiler needs the actual definition of type T, since you are now using type T inside the function body.
TomJons Posted - Aug 08 2018 : 09:37:20 AM
Yes Add Include working well
feline Posted - Aug 07 2018 : 06:23:13 AM
Is VA offering "Add Include" for the type T in this situation? If VA does not know that this is a valid type then it won't offer to add a forward declaration either.
TomJons Posted - Aug 06 2018 : 3:48:13 PM
Sorry, you misunderstand me...

In given example I would like to add forward declaration of type T, NOT function fun, see below:

void fun(T&, T*)
{...}

Expected result:

class T;
feline Posted - Aug 06 2018 : 1:15:14 PM
It turns out that add forward declaration is not currently designed to add a forward declaration for a function call, only for actual types. Adding a forward declaration for a function seems a reasonable extension, so I have put in a feature request for this:

case=118238

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000