Can I use Visual Studio's testing facilities in native code? - c++

Is it possible to use Visual Studio's testing system with native code? I have no objection to recompiling the code itself under C++/CLI if it's possible the code can be recompiled without changes -- but the production code shipped has to be native code.
The Premium Edition comes with code coverage support which I might be able to get cheaply from my University -- but I can get the Professional Edition for free from DreamSpark -- and that's the only thing I can see that I'd use. (But I'd use it a LOT)

Well, I hate to answer my own question, but the answer is no:
This is not going to fly, you cannot use any unmanaged code when compiling safe. That prevents use of any of the unmanaged CRT headers.
Unit testing requires /clr:safe. In other words, no, this is not supported. sigh

Related

MQL4 to C++ dll on microsoft Visual Studio 2017 Community

How can I create a DLL file in Microsoft Visual Studio 2017 Community that can not be decompiled
and transfer functions from my mq4 indicator to the DLL file and connect them together?
I do not know any language other than MQL4
I have not heard of any MQL programs being reverse engineered with the current compiler. The best way (in my opinion) in a DLL will be to write it in C++. Writing it in a DOTnet language will allow others to reverse engineer your code unless it is obfuscated. However, obfuscated code cannot be used to communicate with MT4.
Current version of MetaEditor has "MQL5 Cloud Protector" option that adds encryption to already pretty good default anti reverse engineering protection of MLQ4/MQL5 executables making cracking it economically unjustified. It's cheaper to recreate algorithm and code it from scratch than to break into exec.

Pseudocode Translation

I started working just a few hours ago on a pseudocode translator, which will translate a specific pseudocode, reguarding work with stacks and queues, to c/c++ executable code. The translator has education propuses.
I am still designing the project.
I've started thinking about how this could be done; I figured that maybe the best way to do this is to, in the first place, analize the pseudocode, change it to make it c/c++ code and then compiling it to make it an exe.
NOW, this would mean that the client machine SHOULD HAVE a c/c++ compiler installed on it.
As I'm working with .NET clases ( System.Collections.Generic.Queue(Of T) and System.Collections.Generic.Stack(Of T) ), I thought that a solution to this would be to use the same compiler visual studio uses to compile c/c++ code.
I've been investigating about this proccess, and as far as I know, the only way to compile c/c++ code by using a visual studio tool, is executing cl.exe from the Visual Studio Command Prompt. I found that information here at MSDN (article about how to manually compiling a c/c++ program)
So my first question is: does the USER versión of .NET Framework (this means, assuming the user DOES NOT have Visual Studio) include a c/c++ compiler? If yes, is it the same included in visual studio, cl.exe? How can I get access to it? If no, is there a free compiler WITHOUT IDE I can include on my translator setup?
Notice that here we're talking about transforming a pseudocode string to executable c/c++ code here, the output string MUST BE COMPILED FROM THE USER PC, that's what the project is about.
There is no compiler included in the .Net framework - it is for running binary files produced by the compiler.
It's possible to get the compiler for free through for example the Visual Studio Express free download scheme. There are some license limitations on that ("no commercial use", if I remember correctly - so that would mean that if one of your customers uses your product, they can no sell the resulting code they have produced [and still be within the contract with MS]). Unfortunately, this isn't "without IDE", but the compiler that is part of the download is usable without the IDE, so if "without IDE" is simply that you want to be able to run the compiler with your program, then it will work.
If you really need a package that contains the compiler (in .Net variant) but no IDE code, then you will have to find a different solution - and for .Net I'm not sure there is one. The DDK (Device Driver Kit) contains the native C and C++ compilers. But it won't, as far as I understand, produce .Net code [I could be wrong].
Edit: It seems like if you are writing your own code, you can compile it using CSharpCodeProvider - however, this is not the same as a command-line compiler of cl.exe.
The long, the short, and the ugly is "no". The only C++ compiler remotely suitable for inclusion as a library is Clang, it's free and not toooooo bad to work with, and you'll have to write your own .NET binding, and don't forget to have fun with providing your own linker and stdlib.

visual c++ and C++ builder

Can C++builder compile any c++ source files.
I don't have a good knowledge in c++. but i have some experience in delphi.
I like to use c++ but confused which one to use
I know that cbuilder has vcl , easy to develop ,easy for delphi developer
But my problem is can it compile any c++ files (vc++ and other source files).
is it compatible with vc++ (excluding MFC and VCL). Can i use any APIs with c++builder
You'll find C++ Builder very comfy coming from Delphi if you don't care about MFC or .NET via C++/CLI etc and just want native C++ then either will work for you. Visual Studio 2010 supports a lot of the new C++0x features which is pretty nice, although they don't have variadic templates yet. I'm not sure how much of C++0x is in C++ Builder as yet but that could be worth looking into as a deciding factor.
It should be able to compile any standards conforming code. If the code uses extensions that another compiler provides, it will more than likely have problems. VC++ has quite a few extensions that are on by default and so someone using that compiler might use them with out realizing what is going on(the same applies to G++ the other major C++ compiler out there.)
In my experience, C++Builder's support for more advanced C++ code is limited. For example, many of Boost's libraries are unsupported in C++Builder, and I've often had to modify other open source libraries to get them to build properly in C++Builder (due to various bugs or limitations in C++Builder's compiler). Simpler C++ code can work without any problems.
So, depending on what C++ libraries / source files / APIs you're wanting to use, getting them to work in C++Builder may be very straightforward, or it may take significant work.
You can download a free version of C++ Builder at www.embarcadero.com. With that, you can test your libraries for compatibility.

What are the differences between Visual C++ 6.0 and Visual C++ 2008?

What are the advantages/disadvantages between MS VS C++ 6.0 and MSVS C++ 2008?
The main reason for asking such a question is that there are still many decent programmers that prefer using the older version instead of the newest version.
Is there any reason the might prefer the older over the new?
Advantages of Visual Studio 2008 over Visual C++ 6.0:
Much more standards compliant C++ compiler, with better template handling
Support for x64 / mobile / XBOX targets
Improved STL implementation
Support for C++0x TR1 (smart pointers, regular expressions, etc)
Secure C runtime library
Improved code navigation
Improved debugger; possibility to run remote debug sessions
Better compiler optimizations
Many bug fixes
Faster builds on multi-core/multi-CPU systems
Improved IDE user interface, with many nice features
Improved macro support in the IDE; DTE allows access to more IDE methods and variables
Updated MFC library (in VS2008 Service Pack 1)
support for OPENMP (easy multithreading)(only in VS2008 pro.)
Disadvantages of moving to Visual Studio 2008:
The IDE is a lot slower than VS6
Intellisense still has performance issues (replacing it with VisualAssistX can help)
Side-by-side assemblies make app deployment much more problematic
The local (offline) MSDN library is extremely slow
As mentioned here, there's no profiler in the Professional version
In the spirit of Joel's recent blog post, I've combined some of the other answers posted into a single answer (and made this a community-owned post, so I won't gain rep from it). I hope you don't mind. Many thanks to Laur, NeARAZ, 17 of 26, me.yahoo.com, and everyone else who answered. -- ChrisN
Well, for one thing it may be because the executables built with MSVS 6 require only msvcrt.dll (C runtime) which is shipped with Windows now.
The MSVS 2008 executables need msvcrt9 shipped with them (or already installed).
Plus, you have a lot of OSS libraries already compiled for Windows 32 bit with the 6.0 C runtime, while for the 2008 C runtime you have to take the source and compile them yourself.
(most of those libraries are actually compiled with MinGW, which too uses the 6.0 C runtime - maybe that's another reason).
I would like to add that it's not the case that applications developed using Visual C++ 2008 must require more DLLs than those developed using Visual C++ 6.0. That's just the default project configuration.
If you go into your project properties, C/C++, Code Generation, then change your Runtime Library from Multi-threaded DLL and Multi-threaded Debug DLL (Release and Debug configurations) to Multi-threaded and Multi-threaded Debug, your application should then have fewer dependencies.
Off the top of my head, the advantages of the new Visual Studio are:
stricter adherence to standards
support for x64 / mobile / XBOX
targets
better compiler optimizations
(way) better template handling
improved debugger; possibility to
run remote debug sessions
improved IDE
improved macro support; DTE allows access to more IDE methods and variables
Disadvantages:
IDE seems slower
Intellisense still has performance
issues (replacing it with
VisualAssistX can help)
runtime not universally available
source control integration not up to
par (although in all fairness VC6
lacks this feature completely)
Did you know that MS VC6's implementation of the STL isn't thread-safe? In particular, the reference counting optimization in basic_string blows up even when compiled with the multi-threaded libraries.
http://support.microsoft.com/kb/813810
Besides the deployment mentioned above, the main advantage of MSVC 6.0 is speed. Because it is a 10 year old IDE it feels quite fast on a modern computer. The newer versions of Visual Studio offer more advanced features, but they come at a cost (complexity and slower speed).
But the biggest draw-back of MSVC 6.0 is its non-compliant C++-Compiler and Library. If you intend to do serious C++-Programming this is a show-stopper. If you only build MFC-Applications it is probably not much of a problem.
Visual C++ 6.0 integrates with memory tracking tools, such as Purify, HeapAgent, BoundsChecker and MemCheck, thoroughly and well since those memory tracking tools were actively maintained and aggressively sold after Visual C++ 6.0 came out.
However, since C++ has been out of vogue for a while, the companies that sell memory tracking tools still sell them but never update or integrate them with new Visual C++ versions, including Visual Studio 2008. So, using memory tracking tools with Visual Studio 2008 is frustrating, errorprone and, in some cases, impossible.
Since VC6 most of the focus of Visual Studio has been on C# and .NET, as well as other features, so some C++ old-timers see VC6 as the good old days. Things have improved in Visual Studio for C++ developers since those days, but not nearly as dramatically as for .NET users.
One way that VS2008 is significantly better than VC6 is that it can build C++ projects in parallel. This can result in significantly faster builds even on a single CPU system, but especially if you have multiple cores.
If you install all service packs for VS6 you still have a solid IDE/compiler combo. As a software developer who have to release products in the wild (over Internet) I don't want to o ship the VC++ runtimes and .NET framework everytime (I can't bundle them directly in my installer/executable, its forbidden by Microsoft). You know, several megabytes of runtimes to run kilobytes of code is kinda stupid. VC++ 6.0 only need your executable and 2 .DLL at best.
Also, debug runtimes cannot be distributed with VC++ .NET, not really good when I have a client which need to do some debugging of my products :)
There is in my opinion the major reasons why I still use VC++ 6.0, but the IDE itself is ugly (ie: no tabbing support). I usually bypass the IDE limitations by using codeblocks instead (CodeBlocks support CL.EXE/LINK.EXE for all VC++ versions)
Cobolfoo
Visual C++ 2008 is much more standards compliant (Visual Studio 6 doesn't support the C++ standard set in 1998).
VS2008 has better compiler (much more standards compliant, better optimizations, ...).
VS6 has much faster IDE. VS2008 IDE has many nice features, but it is a low slower than VS6.
Quick list of improvements you'll see going from 6.0 to 2008:
Many bug fixes
Better conformance to the C++ standard
Better compiler optimization
Improved UI (better intellisense, etc)
One thing that people sometimes forget is that VS 6.0 is over 10 years old now! At this point, I don't see how anyone would want to stick with it.
one tough thing we encountered was that "value" became a keyword.
Visual C++ 6 can be very buggy at times compared to 2008. Some things in particular:
Poor template support/oddities (for instance sometemplate<othertemplate<t>> not working, but sometemplate< othertemplate<t> > working)
Not standards compliant
Resource editor is rubbish ("blue lines" seem to move around randomly, among other things)
Only supports editing certain kinds of 8-bit bitmaps (I have to use imagemagick to convert bitmaps saved in paint.net to be able to be seen in picture resources)
Terrible support for working with read-only files / quirky sourcesafe integration.
Sometimes developing in VS6 feels like trying to get websites looking good in internet explorer 5.5

C on Visual Studio [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm trying to learn C. As a C# developer, my IDE is Visual Studio. I've heard this is a good environment for C/C++ development. However, it seems no matter what little thing I try to do, intuition fails me. Can someone give good resources for how to either:
learn the ins and out of C in Visual Studio
recommend a better C IDE + compiler
Edit: See also: https://stackoverflow.com/questions/951516/a-good-c-ide
well you can use visual studio just fine take a look at here man
http://www.daniweb.com/forums/thread16256.html
Go to View Menu select Solution Explorer or CTRL+ ALT +L
Then Select The project that your are developing and right click on that.
Then select the Properties from the submenu.
Then select the Configuration properties from the Tree structure. under that select C/C++ then select Advanced. Now in the right side pane change the property
Compile As from Compile as C++ Code (/TP) to Compile as C Code (/TC)
Finally change your file extensions to .c
Now you configured you Visual Studio to compile C programs
And you can use NetBeans too it could even be more user friendly than Visual Studio download it you wont regret i promise
The problem with learning C within Visual Studio is that you are compiling C using the Visual Studio C++ compiler. You might want to try learning C using the GNU GCC compiler from within the Cygwin environment in Windows.
Answering the purely subject question "recommend me a better C IDE and compiler" I find Ming32w and Code::blocks (now with combined installer) very useful on windows but YMMV as you are obviously used to the MS IDE and are just struggling with C.
May I suggest you concentrate on console applications to get a feel for the language first before you attempt to tie it together with a windows UI which in my experience is the hardest bit of windows development.
Simple and sweet: Console applications (basic C programs using printf and such) are easily and cheaply done with the Tiny C Compiler - a no frills, no gui, complete C complier.
http://bellard.org/tcc/
However, C development is relatively simple on Visual Studio as well. The following instructions will set Visual C++ up as a good C compiler, and it will produce console applications at first, and yo can move up into more complex windows apps as you go.
Get the Visual Studio C++ edition (express is fine)
Start a new project - disable pre-compiled headers (maybe the wizard will let you do this, maybe you'll have to change the compiler settings once inside the project)
Delete everything inside the project.
Create a new "example.c" file with the hello world example
Compile and away you go.
Alternately, get a linux virtual machine, or Cygwin. But as you already have Visual Studio, you might as well stick with what you know.
As an aside, this isn't Atwood learning C finally, is it? No ALTs! ;-D
-Adam
Bloodshed Dev-C++ is the best windows C/C++ IDE IMO: http://www.bloodshed.net/
It uses the GNU compiler set and is free as in beer.
EDIT: the download page for the IDE is here: http://www.bloodshed.net/dev/devcpp.html
As already said, you should check out the VS.net C++ edition, but if you'd like to try something else Eclipse has a C++ edition. You can get more info from http://eclipse.org or check out the distro at http://www.easyeclipse.org/site/distributions/cplusplus.html
The problem with learning C within Visual Studio is that you are compiling C
using the Visual Studio C++ compiler. You might want to try learning C using
the GNU GCC compiler from within the Cygwin environment in Windows.
This is a legitimate response, I posted an IDE that uses the GNU compilers, so why has he been down modded?
This is the type of thing that will make me not use SO, why down mod someone just because they are recommending a different compiler, and IMHO, a better one then Microsoft's?
get real people, and #Antonio Haley I gave you +1
http://xoax.net/comp/cpp/console/Lesson0.php
Any use?
Some people say that a smaller IDE is better for learning. Take a look at Code::Blocks. It's generally true that beginning C in an IDE is hard because not many books explain enough to control the IDE. Perhaps starting in a console and a basic text editor with syntax highlighting would be better – at least under Linux. Since Windows' console is far from great, I'd not recommend using it.
/EDIT: Dev-C++ used to be the best freely available IDE for Windows. However, it's development has been discontinued years ago and the most recent version unfortunately is full of bugs.
There's a very good reason to learn C and C++. The reason is that there's a lot of C and C++ code out there that are performing very real and important tasks. Someone who considers themselves a programmer and a learner(doubtful that you can separate the two) can learn a lot from these lines of code.
You can learn a lot from each language by studying the other, but if you really want to grok C it's a lot easier to separate yourself from anything C++ for a while. Visual C++ is great but GCC is a great way to thrust yourself into vanilla ANSI C without having to mentally sidestep any C++.
#mmattax thanks!
C in Visual Studio is fine, just use the command line compiler that is included in the Pro edition. Yes its the C++ compiler but treats all files ending .c as C . You can even force it to treat ALL files as C with a switch. The VS documentation has entries on it, just search the index for Visual C.
Visual Studio is one of the best IDEs for C/C++.
I don't think it is complicated and hard to use - if you have questions about it - ask them.
Some other compilers/IDEs are fine too, but if already have Visual Studio and have used it - why not stick to it?
For plain C, I suggest Pelles C. Generates optimized code and supports C99 constructs.
Features:
Support for 32-bit Windows (X86),
64-bit Windows (X64), and Windows Mobile (ARM). Support for the C99 standard.
Integrated source code editor with call tips and symbol browsing. Integrated source-level
debugger. Project management.
Inline assembler for X86 and ARM.
Integrated resource editor. Integrated bitmap, icon and cursor editor. Integrated
animated cursor and video editor.
Integrated hex-dump editor.
Supportfor custom controls in the dialog editor. Support for custom project wizards.
http://www.smorgasbordet.com/pellesc/
When i used visual studio 5.0 it should compile c code as long as the header files and lib. are there for the compiler to find. In fact most C++ compilers like G++ will compile C code just fine. But i'm not sure how well.. If you are targeting a platform then you can change the header files and lib. within you IDE and Compiler.
Visual Studio has a great debugger that no other Compiler that i have seen can compete with. I have been using gcc darwin10 4.2.1 and find the debugger is basically just the one you can getfree with any linux flavor. I recommend you learn both on a plain vanilla gcc compiler and also try visual studio which costs money. The express edition does not allow the use of threading and several other things that I forgot about. Visual Studio 5.0 should be ok to use and the debugger is much more human friendly then the one commandline version called GDB. Try DDD on linux which is similar to XCODE's debugger.
Although C++ and C are different you can compile both together. But you should understand each ones flaws and good points. C code is faster, but C++ is much easier to write and manage larger code. C++ is object oriented but C is procedural while they are both imperative languages. I would suggest learning objective-C since you can use both C++ and C libraries. Using the features you like in all three languages!!!
Visual Studio or Express do consider .c files as C code, but the compiler will keep giving warnings, and irritating suggestions which you do not require, in the debugger. Gives an indication that Visual C++, as the name suggests is optimized for C++ development for the Windows Operating system, which was originally written in plain pure C.