I just started converting a library project from Delphi to C++ in VS2005.
How can I do simple things familiar from Delphi IDE like:
complete the C++ class (in Delphi Ctrl+Shift+C)
quick move from method declaration to its definition (in Delphi Ctrl+Shift+Up/Down)
Note: I must use VS2005 for this project.
Thank you
C++ IDEs don't have equivalent functionality to class completion. The IDE cannot complete classes because it does not know how to do so. Definitions can be provided in many places, in defining declarations, later in the same file, in another file, in a library.
To move from definition to declaration you can the F12 shortcut, also available from the menus.
Related
I'm new to Visual Studio Code (on Mac). We are using it to develop ASP.NET Core MVC applications in C#. When I hit F12 on a symbol, like classes, interfaces or variables, VS Code will jump to the definition of that symbol if the definition exists in the source files, sweet. However nothing will happen if the definition is from an external dependency. If I did this with Visual Studio on Windows, in this situation the default behaviour is jumping to the definition provided by its metadata. Is there a similar way in VS Code to do this, rather than doing nothing in this case? It would be very helpful during development.
The new OmniSharp C# extension for VS Code for >=.NET Core 1.0 now has this feature. If there is no source code available then jump to the definition provided by its metadata. (Since OmniSharp C# extension 1.6.0 for VS Code which I used. But the legacy OmniSharp C# extension for DNX doesn't have this feature)
Is there an automated way within Visual Studio to convert a project of type Portable Class Library to a regular (platform-specific) Class Library?
I need to reference a library which doesn't happen to be portable.
You have to edit your PCL's .proj file.
I'm not aware of anything within visual studio itself but the steps are easy enough to do yourself.
See my answer here
I am trying to learn Interop from C# and C++/CLI. I am starting with creating a C++/CLI project. Most of the examples I found talks about interop with COM however when I am creating a C++/CLI project in Visual studio 2010, under the project templates for Visual C++ project, I don't see any type for COM. Any ideas? Also can I create just a Visual C++ Class Library project to use for this purpose?
You are mixing it up. There are three distinct ways to interop with native code from a managed program, you don't use them all at the same time:
pinvoke through the [DllImport] attribute. Good for C style native APIs
interop through COM. Very well supported by the CLR as long as it is the Automation subset and you have a type library. Just works out of the box, no work needed. Adding COM to existing native code that isn't COM enabled is not productive unless you already have good COM programming skills (know ATL)
wrapper classes created in the C++/CLI language. When the above options are not enough. Required for interop with native C++ classes.
Learning enough C++/CLI to get the job done requires about 3 weeks, truly learning the language is a multi-month effort. Things to focus on when you just use it for writing wrappers is #pragma managed, the proper use of the hat and the difference between the destructor and the finalizer.
It is possibly worth your time to learn more about it, the syntax heavily resembles the syntax of C++/CX, the language extensions added to the MSVC++ compiler that support writing Metro apps for Windows 8. Knowing C++/CLI is 95% of knowing C++/CX.
Sample quick-start wrapper class in C++/CLI in this answer.
Can we 'easily' (in some way) compile C++Builder project into VisualStudio 2005 C++. New in C++ i'm looking for references in that matter (CBuilder vs VS). Thanks.
Well, not really. It's true that the "pure" C++ parts should compile, you have two very big gotchas to deal with:
First, Borland made some proprietary extensions to C++ to make it compatible with their Delphi products. I don't remember what these are offhand, but they could be a problem depending on what you're doing.
But the main problem is the VCL, the main GUI library. If you're developing in C++Builder, then 99% of the time you're using the VCL, and using it rather heavily. AFAIK, the VCL will not compile under any Microsoft compiler for many reasons, including the one I already mentioned.
So basically, you're stuck porting to .NET ( or MFC or whatever if you're a masochist) if you want to get this running under VisualStudio. One bright spot here is that many 3rd party component developers have embraced .NET, so you may not have to do as much work to port the project as you think.
If you use the VCL classes you won't be able to compile your code in Visual C++. The VCL introduces some new language structures to the C++ language, to make it compatible with delphi, __property etc. And even if you can move the VCL code to some external dynamically linked library there will still be a lot of problems calling the VCL functions. This is because the Borland __fastcall calling convention differs from most other compiler implementations of it. The Borland version passes 3 arguments to registers, while most other compilers use 2.
All in all there can occur a lot of problems from different compiler implementation, in particular if you use the VCL or the __fastcall calling convention. The thing about C++ Builder is that it is build to be compatible with Delphi and the VCL, and while the VCL is an excellent framework for RAD and GUI programs, it adds the cost of less compatibility with other compilers.
Well, it's all C++ in the end, so you can include your C++Builder files into a VS2005 solution and link the libraries in. VS2005 would much rather see MFC or .NET than all of the Turbo classes from C++Builder, no doubt. Importing resources may be an issue too.
I'd be interested in other answers here as well. We may need to travel down this same path on our project.
Go To definition in Visual studio 2005 works only for files that are in my project. It never works for files that are included in external libraries like mfc. When I say Go To Definition for mfc function it always shows me the header file . Is this expected behavior?
And also how does this whole thing Go To Definition work?
Thanks
I'd make the small investment required in Visual Assist. Besides all the great features it offers, it has the Alt+G command which works way better than the Visual Studio go to definition :)
For the MFC source files (at least the Feature Pack ones) I learned to find out what folder are they in (usually at C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc) and add that folder to the Find in Files dialog.
It's not as direct as Go to Definition, and you may have to browse among the find results, but it works...
Note: I second #flippy's answer of Visual Assist, it's really great.
External libraries are references to their compiled DLLs rather than the source when referencing your own projects.
The idea is that you don't need any more than the interface to external classes, but, if you would like to see the internals of DLLs you can use a tool such as Reflector.
Yes only the interfaces for MFC will be given in header file.Unless it is implemented with Template you will not be able to access the actual definition.The dlls have implementation for those interfaces.
Well if you think about it logically, as far as visual studio knows the only definition of the MFC object that is available is the definition it sees in the associated MFC header file, so unless you actually have the entire source for MFC it won't be able to look anywhere else.
The way that intellisense/go to definition works is via a file that is created when you compile the application. It stores a mapping between variables/functions and where they are declared (or could potentially be declared, in polymorphic situations), and when you right click to say "go to definition" it references that file.
Yes this is the expected behavior. Only the declarations (header files) of the MFC code are available on your box and hence that is the only location that it can take you to.
What are you expecting it to show?