 <p>I take what I previously said back. I think I may have a way to make this work in pure c/c++, albeit in a very messy way. You would need to pass a pointer into your functions...</p> <p>i.e. bool hello_world(std::string &amp; my_string, const std::string * const my_string_ptr) {</p> <p>bool hello_world(std::string my_string, const std::string * const my_string_ptr) {</p> <p>if you now tested</p> <p>if ( &amp;my_string == my_string_ptr )</p> <p>It would evaluate <strong>true</strong> if the var was passed by reference, and false if passed by <strong>value</strong>.</p> <p>Of course doubling your variables in all your functions probably isn't worth it...</p> <hr> <p>Johannes is right... not in pure c++. But you CAN do this. The trick is to cheat. Use an embedded scripting language like perl to search your source. Here's an embedded perl module:</p> <p><a href="http://perldoc.perl.org/perlembed.html" rel="nofollow">http://perldoc.perl.org/perlembed.html</a></p> <p>Pass it the function name, variable name, and source location and then use a regex to find the variable and check its type. Really this might be a better solution for your code in general, assuming you are always going to have a source handy. </p> <p>I will post a function for this basic approach in a bit... gotta take care of some morning work! :)</p> <p>Even if you don't want to distribute the source, you could create some sort of packed function/var data file that you could parse through @ runtime and get an equivalent result.</p> <hr> <p><strong>Edit 1</strong><br></p> <p>For example... using the <code># I32 match(SV *string, char *pattern)</code> function in the Perl Embed tutorial, you could do something like:</p> <pre><code>bool is_reference(const char * source_loc, const char * function_name, const char * variable_name) { std::ifstream my_reader; char my_string[256]; SV * perl_line_contents; bool ret_val = false; char my_pattern [400]=strcat("m/.*",function_name); my_pattern=strcat(my_pattern, ".*[,\s\t]*"); my_pattern=strcat(my_pattern, variable_name); my_pattern=strcat(my_pattern, "[\s\t]*[\(,].*$"); my_reader.open(source_loc.c_str()); while (!my_reader.eof()) { my_reader.getline(my_string,256); sv_setpv(perl_line_contents,my_string); if(match(perl_line_contents,my_pattern)) { ret_val= true; } } return ret_val; } </code></pre> <p>... there... two ways to do this (see above update).</p>