This question already has answers here:
Code Metrics Analysis for Unmanaged C++ Code [closed]
(4 answers)
Closed 8 years ago.
I work on a little C++ open source project.
I need to get some metrics out of it.
To do so, Visual Studio requires the code to be "managed".
Simple question (expect simple answer) : how do I get metrics from native projects ?
Thank you very much.
Change your project properties to "Use Common Language-Runtime (/clr)".
This will cause the compiler to emit .NET metadata for functions and variables in the program, and the profiler/analyzer relies on this metadata.
Sometimes the metadata is less complete for standard C++ code than for .NET types. And you surely don't want to rewrite everything over to C++/CLI, managed types, .NET runtime, garbage collection.
But trying a compile with /clr enabled shouldn't hurt anything.
Related
This question already has answers here:
How to write portable code in c++?
(12 answers)
What is "Portable C++"? [duplicate]
(2 answers)
What is meant when a piece of code is said to be portable? [closed]
(3 answers)
Closed 4 months ago.
The community reviewed whether to reopen this question 4 months ago and left it closed:
Original close reason(s) were not resolved
Not sure if this is the right place to ask this:
How do programs written in c++ run on other computers if you don't write them specifically to do that? I saw something about not just sending the .exe, but also sending other things with it?
Is there a high level programming language that is as fast or nearly as fast (in run speed) as c++ while also being platform independent?
See above.
You compile your code for all the platforms you target and deploy a number of executables. Hence, Write once, compile anywhere.
C++ allows you to write portable source code. So assuming you write portable code to start with, you can compile it for some target platform, and run the resulting binary on that target.
Now, depending on what your program uses, you may have to package other "stuff" with the executable. What you mention ("I saw something about not just sending the .exe, but also sending other things with it?") would arise if your program used some dynamic link libraries that were not part of the OS (presumably Windows, based on the mention of .exe). But, it's kind of up to you to decide whether to use a library that's packaged as a DLL or not. If you don't want to package DLLs with your executable, don't use them (but sometimes, you may decide it's less trouble to use and package the DLL than do without).
As far as another language goes...doesn't really make a lot of difference as a rule. If you write code that depends on something else, you have to satisfy that dependency on the target computer. Some languages require you to add some DLLs to support the language itself, but most C++ compilers don't. On other OSes, those dependencies won't be called "DLLs", but most reasonably modern OSes provide something similar.
This question already has answers here:
Is it possible to "decompile" a Windows .exe? Or at least view the Assembly?
(16 answers)
Is there a C++ decompiler? [closed]
(5 answers)
Closed 4 years ago.
I lost the source code to an executable file but still have the actual file. Is there any way to retrieve the original C++ code?
Duplicate of this question here.
Yes, it is possible, however when it comes to peeking function bodies and the like, you might have a little less luck. Operating systems like Kali Linux specialize in de-compilation and reverse engineering, so maybe look into a VM of that. And of course, windows has a lot of applications you can use as well to check the application code.
Look over the other question for specific app suggestions. :)
Edit : You will most likely have lost all your logic and function bodies, but you might be able to recover the overall structure. It's your EXE so you might be more familiar with how it was all connected up.
You cannot get the original source code but you can decompile the binary into source code using tools given in this similar question: Is there a C++ decompiler?
The output source code will not look like the original as the compiler will have optimised the original source when generating the executable.
Short answer NO.
Long answer, because C++ doesn't use some intermediate code like C# or Java you cannot decompile the app in some readable format. But if you can read assembly maybe you can save some time.
This question already has answers here:
Using C++ to edit the registry
(5 answers)
Closed 9 years ago.
I'm relatively new to coding (even though I've taken a few classes on it) and picked up a job working IT at the library on campus. I do Windows Updates on the computers and come across an error that requires me to alter the registry value of the Windows Update Service. I would like to write a code to do that for me automatically, because it is rather time consuming to alter the registry on five hundred computers. Where do I start? Is it even possible?
To make the changes, I open:
HKEY_LOCAL_MACHINE
Software
Policies
Microsoft
Windows
WindowsUpdate
AU
UseWUServer (this is where I change the value to 0)
In Vista or greater than systems you will need elevated privileges to run anything that will modify the registry. Both answers above would work, I personally have found using power-shell scripts very powerful for this type of problem.
This question already has answers here:
Is there a command like "watch" or "inotifywait" on the Mac?
(16 answers)
Closed 9 years ago.
i require a callback within my code (in C++) which fires every time a particular file is modified (after a save), i am using a Mac however not Xcode, i am building my code using g++, documentation for this seems to be very limited. Does anyone have any example code which performs this functionality? Or can point me in the right direction as to where to look?
On Linux you would use ionotify, but OSX has FSEvents. It seems it will only notify you about changes to directories, it's up to you to then see if the event was about your file or not. There's a C API. This question has some examples.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What open source C++ static analysis tools are available?
Does anybody know of an open source,good static code analyzer for C++ code in Linux ?
The idea is to catch programming errors even before the code goes in to the code review state.
It would be great to have the possibility to add rules the tool.
Does anybody know of such tool?
lint, found here: http://en.wikipedia.org/wiki/Lint_(software)
cppcheck, found here: http://cppcheck.wiki.sourceforge.net/
you can give a try pvs-studio:
http://www.viva64.com/en/pvs-studio/ (1)
also there is (bla-bla-lint):
http://www.gimpel.com/html/index.htm (2)
missed note about linux,
FlexeLint for C/C++ from (2) has linux support,
(1) only for windows, you can check it only if your product crossplatform.
You can also customize GCC (4.6) by using plugins (coded in C) or MELT extensions (MELT is a high-level domain specific language to extend and customize GCC). This approach could be appropriate if you have your own coding rules that you want to check. However, it does take some work.
Take a look at clang's static analizer: http://clang-analyzer.llvm.org/
There are other tools like KLEE based on llvm, might worth a look, too.