This question already has an answer here:
Keep the delegate argument names when compiling C++/CLI for .Net
(1 answer)
Closed 8 years ago.
I'm working on a multi-project program in C++/CLI and parameter names for functions, constructors etc. are not showing up properly in the Intellisense window. When I start typing a function call within the project, all goes well, but as soon as I use said project in another project (still within the same solution), VS shows funky parameter names (e.g. myobj.move(int A_0,int A_1)) instead of the names I gave them in the code. I've tried using the ///<param> thing, but that works only within the same project, not in other projects (again, in the same solution). I've enabled the /doc option in the project properties, but that didn't do it. Is there a way to feed the generated XML file (or .xdc I guess?) into Intellisense? Thanks in advance!
This happens when you declare the function prototype in a header file without the argument names:
#file.h
ref class A
{
void move(int ,int );
}
You should just add the names you want:
file.h
ref class A
{
void move(int MyArgument1,int MyOtherArgument);
}
Related
I am following this tutorial
and like many other tutorials, it is very vague as to where to insert code. Which vb.net file would I insert the host class to begin adding the using statement?
I have a file called crawler.aspx...this accepts html and the like. I also have crawler.aspx.vb...tried adding the code there and received an error saying that the statement could not be used outside of the method/body lambda.
The code example is in C#. The equivalent VB.NET directive is Imports. It tells the compiler that you will be using classes and methods and such from the specified assembly.
As long as you have a reference to the assemblies in your project (which if you installed this via NuGet you should), you can simply add the following lines to the top of your file containing the code of the host class, like this:
Imports Abot.Crawler
Imports Abot.Poco
This should not be confused with the Using statement, which is something different entirely.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Dynamically creating functions in c
Here is an example of what I'd like to do:
void attribute((constructor)) someFunction() {
// Would be nice to define C function "someFunction2" somehow here.
}
I know class_addMethod allows adding C functions to Objective-C classes during runtime.
Is it possible to add C function to C main space?
Please, don't tell me I'm wrong if I'm thinking about this way of doing things - I am interested in it rather for educational purposes.
No. A C function consists of a name and a body. The compiler transforms the body to a binary piece of executable code that will be mapped to some address when a process is created from the executable. The name is used by the static and dynamic linkers as an alias to this address.
At runtime both concepts aren't really of much interest. The executable is loaded and names are resolved, so there's little use in creating them dynamically.
On iOS it would even be impossible to create new function implementations as the kernel disallows to make memory executable.
I created a new Metro Split App in C++ using VS2012 on Win8 (both RC). Everything compiled and worked out of the box. I then changed went through and changed the generated namespaces to my own. After some trials and tribulations, I got everything to compile with no warnings, errors, nor messages. The app (as it comes in the project template) runs fine.
However, if I try to edit either of the generated xaml files (ItemsPage.xaml or SplitPage.xaml) I get a "Markup error" on the first line:
The name "LayoutAwarePage" does not exist in the namespace "using:A.B.Product.Client.Common".
The definition of the class is:
namespace A{ namespace B { namespace Product { namespace Client { namespace Common
The code compiles fine, and runs fine. This only happens in design mode.
UPDATE: I added a new xaml file and (after fixing up the namespaces again) everything worked.
Please let me know if any additional information is needed.
The name of the WinMD file produced by your project must be some prefix of the namespaces in which the public WinRT types are defined. Given that your type is in the A.B.Product.Client.Common namespace , the WinMD file must have one of the following names:
A.winmd
A.B.winmd
A.B.Product.winmd
A.B.Product.Client.winmd
A.B.Product.Client.Common.winmd
The public types must also be defined in the WinMD file with the longest prefix that matches the namespace. So, if you have both A.winmd and A.B.winmd, the type A.B.MyClass must be defined in A.B.winmd.
So, why does your code work at runtime but not in the designer? The naming rules for public types only apply to types defined in Windows Runtime components (for C++, DLL files), not for applications (EXEs).
However, to be able to instantiate your user-defined types (including LayoutAwarePage), the designer will load your project's EXE as a DLL, so the naming rules must be followed.
I had a similar bug, but then I closed VS, deleted the .suo, and reloaded the project and everything worked just fine.
I was convinced that there is no way to find COM dependencies of an ActiveX but to my surprise OLEVIEW shows some comments Like:
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// TLib : Visual Basic runtime objects and procedures : {EA544A21-C82D-11D1-A3E4-00A0C90AEA82}
importlib("3");
I tried to extract the same information using TypeLibInfoFromFile but based on what I find in MSDN, there is no Api that provides this information. Are you aware of a method to extract this information from OCX or it's Tlb file? Knowing that all my ocxes are compiled with vb6 can I trust this informaion for Imported(Explicitly not in code) interfaces?
Well, I've found the answer to this question. I'll write it here just in case someone would search for the same question. It's possible to find some of dependencies but you can never be sure if you have found them all. Basically you must enumerate every type and interface, and every member of each type to find all types in the module and for every type you find you should check to see if it's in an external TypeLib. in the end you have a List of Typelibs referenced.
The problem with this method lays in the fact you find only the types that are used in the public interface (fields, return values and parameters) and you miss every local object or dynamically created ones. That said you can check this link for an implementation or better yet this one.
I have the following static function:
static inline HandVal
StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards )
Can I export this function in a DLL? If so, how?
Thanks,
Mike
Background information:
I'm doing this because the original source code came with a VS project designed to compile as a static (.lib) library. In order to use ctypes/Python, I'm converting the project to a DLL.
I started a VS project as a DLL and imported the original source code. The project builds into a DLL, but none of the functions (including functions such as the one listed above) are exported (as confirmed by both the absence of dllexport in the source code and tools such as DLL Export Viewer). I tried to follow the general advice here (create an exportable wrapper function within the header) to no avail...functions still don't appear to be exported.
You may not export that function from a DLL. static functions are equivalent to private to that file.
You can create a method in the file that calls it and export that.
By defining a function with static and inline you are effectively guaranteeing that it will be only in the modules that includes the definition.
Either edit each file to remove the static inline (which might break) or change everything to use a PreProcessor directive that will allow you to have either:
#define MYAPI static inline
or
#define MYAPI __declspec(dllexport)
and then
MYAPI HandVal StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards )
or build a set of wrappers as a seperate module which does
__declspec(dllexport) HandVal Public_StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards )
{
return StdDeck_StdRules_EVAL_N(cards, n_cards);
}
As Romain said, a static function is private to the file and you can't export it.
You can try:
export the entire class
try make the static method a static inline method.
The compiler is free to inline such a function at the call sites (which is more likely to happen the less those call sites are, among other factors) (which is what you've done already, so I'm guessing this didn't work in your case 12 years ago. :D)