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
 Indirect functions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

foxmuldr
Tomato Guru

USA
402 Posts

Posted - Aug 17 2013 :  10:30:30 AM  Show Profile  Reply with Quote
I often use indirect functions (for plugins and what not), which are like this:
// Definition of external plugin
int (*foo) (void);

// Usage of remote plugin function
foo();


Within the solution I have the actual plugin function definition in another project, its body, and local usage:
// Prototype definition
int foo(void);

// Function body
int foo(void)
{
    // Code here
}

// Local usage
foo();


-----
Is there a way to have the symbol which points back to "int (*foo) (void)" have the option under "go to declaration" and "go to definition" to choose either that definition, or the real one in the other project? This would only be on items which relate back to a pointer to a function which also has a real function definition of the same name, return, and parameters.

Today it says: "The symbol 'foo' is not found" and I have to leave that project, go to the other one, and then do a manual search with CTRL+F.

An example of this usage can be found here:
For plugin (line 349): http://tinyurl.com/vvmoss1
For local (line 49): http://tinyurl.com/vvmoss2

TIA!

Best regards,
Rick C. Hodgin

Edited by - foxmuldr on Aug 17 2013 2:54:00 PM

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Aug 19 2013 :  2:52:05 PM  Show Profile  Reply with Quote
This is a standard function pointer. In your actual code, are you actually using the same name for the local function and the function in the external plugin that you are pointing at?

When ever I have used function pointers I have always used different names, just to make it easier to track what I am doing. I am just wondering how you tell the function pointer what it is pointing at if the names are the same. I am not seeing any sign of the function pointer being a struct or class member in the example you have linked to.

I have set up a very simple test case, for a function pointer being declared and used, and alt-g is working correctly here:

void felineFunctionToPointAt(int x)
{
	printf( "%d\\n", x );
}

void testUsingFunctionPointer()
{
	void (*felineFuncPointer)(int);
	// alt-g on "felineFunctionToPointAt" here goes to the actual function implementation
	felineFuncPointer = &felineFunctionToPointAt;

	// alt-g on "felineFuncPointer" on both of these lines goes to the function pointer declaration
	felineFuncPointer( 2 );
	(*felineFuncPointer)( 2 );
}

zen is the art of being at one with the two'ness

Edited by - feline on Aug 19 2013 2:52:50 PM
Go to Top of Page

foxmuldr
Tomato Guru

USA
402 Posts

Posted - Aug 20 2013 :  10:55:15 AM  Show Profile  Reply with Quote
Same name for the indirect function pointer and local functions. The original definition file is included in the one project that compiles to its own DLL. For all other DLLs it includes the external definition through the function pointer, but always the same name.

If you have Visual Studio 2008, or don't mind upgrading the solution to a later version, do:

c:
cd \git clone [email protected]:RickCHodgin/libsf.git


(1) Open the "buildall.sln" solution in libsf\\vvm\\core\\ and rebuild all (is a quick build, 15 seconds).
(2) Close the solution.
(3) Open the "vvm.sln" solution in the same directory and rebuild all (is a quick build, 15 seconds).
(4) Open \\libsf\\vvm\\core\\vvmtests\\vvmt_core\\vvmt_sll4_test.cpp. This is a source file in the vvmt_core project. If you open vvmt_core.cpp you'll see the header files at the top. One of them is common_vvmoss.h, which contains all of the function pointers.

(5) Back in vvmt_sll4_test.cpp, locate one of the oss_ll4_*() function references (such as around line 1309 for the version that's out there now), and
(6) right-click on it and
(7) choose "go to definition" or "go to declaration".

It's not found.

But if you hover over it you'll see the explanation of that function shown as a popup.

And if you go to the common_vmmoss.h file you'll find the reference, and you can search for it by name manually and find it. Going also to c:\\libsf\\vvm\\core\\vvmoss\\vo_defs.h you'll find the original prototype definition, and in c:\\libsf\\vvm\\core\\vvmoss\\vo.cpp you'll see the function body.

A lot of steps I know. It's actually easier than it sounds. :-)

Perhaps there is something in common.h or a higher .h file which is causing the parsing to be thrown off so it's not found?

Maybe my version of VS2008 is not working properly?

Edited by - foxmuldr on Aug 20 2013 10:58:31 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Aug 20 2013 :  1:04:19 PM  Show Profile  Reply with Quote
Got there in the end, thank you for the very clear and detailed instructions The main problem was getting a git client installed and working, but after a few attempts I got one working.

I am using VS2008, VA 1949, and sitting in the file:

c:\\libsf\\vvm\\core\\vvmtests\\vvmt_core\\vvmt_sll4_test.cpp

at line 1310, which is:

ll4 = oss_ll4_create(NULL, NULL, NULL, NULL, oss_getNextUniqueId(), tnSize);

right click and "go to definition" or "go to declaration" are IDE commands, that have nothing to do with VA. A common point of confusion. However, they both work, or at least do something, when I trigger them. They both take me to:

c:\\libsf\\vvm\\core\\common\\common_vvmoss.h - line 577

are they doing anything at all when you trigger them?


Alt-g is the default keyboard shortcut for the VA go to command, and this is showing me a menu with 3 possible options. I have:

vvmoss\\vo.cpp - line 4975
common\\common_vvmoss.h - line 577
vvmoss\\vo_defs.h - line 266

How close is this to what you are seeing?

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

foxmuldr
Tomato Guru

USA
402 Posts

Posted - Aug 21 2013 :  4:31:40 PM  Show Profile  Reply with Quote
quote:
Originally posted by feline

Got there in the end, thank you for the very clear and detailed instructions The main problem was getting a git client installed and working, but after a few attempts I got one working.


Excellent!

quote:
I am using VS2008, VA 1949, and sitting in the file:
c:\\libsf\\vvm\\core\\vvmtests\\vvmt_core\\vvmt_sll4_test.cpp
at line 1310, which is:

ll4 = oss_ll4_create(NULL, NULL, NULL, NULL, oss_getNextUniqueId(), tnSize);

right click and "go to definition" or "go to declaration" are IDE commands, that have nothing to do with VA. A common point of confusion. However, they both work, or at least do something, when I trigger them. They both take me to:

c:\\libsf\\vvm\\core\\common\\common_vvmoss.h - line 577

are they doing anything at all when you trigger them?


I'm using VS2008 and VAX 1929 on this virtual machine, on both I get "The symbol 'oss_ll4_create' is not defined."


quote:
Alt-g is the default keyboard shortcut for the VA go to command, and this is showing me a menu with 3 possible options. I have:

vvmoss\\vo.cpp - line 4975
common\\common_vvmoss.h - line 577
vvmoss\\vo_defs.h - line 266

How close is this to what you are seeing?



100% on this part!!!! I didn't know about Alt+G! Woo hoo! :-) That is *EXACTLY* what I was looking for. Thank you.

VAX just keeps getting better! :-)

Thank you, feline!
Go to Top of Page

foxmuldr
Tomato Guru

USA
402 Posts

Posted - Aug 21 2013 :  4:33:54 PM  Show Profile  Reply with Quote
I am so happy now. This has been a huge issue of contention for me because most all of the development I do is outside of the main project which contains the real function body, but rather everything is through the pointers.

THANK YOU AGAIN! :-)
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Aug 22 2013 :  09:54:06 AM  Show Profile  Reply with Quote
I am not sure why the IDE's go to commands are having problems here, but thankfully that does not really matter. I am glad this is working so well for you

If you have any other problems please let us know, and we will do everything we can to fix them

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