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 6 years ago.
Improve this question
I am developing some c++ code, but having code separated in to .h and .cpp is driving me mad, as it is slowing down re-factoring.
Is there a tool that lets one work on a single file. An editor that just hides the truth, or a per-processor that takes a single file and produces the two files .cpp and .h
clarification:
I want a single file per compilation unit (like Java, C♯, Eiffel). I will still have to have #include in files to include the headers of other modules. (but then Java and c♯ have import and using).
clarification 2:
Things are easier if everything that should be together is together.
i.e. one and only one file per class.
There's Lzz. I haven't tried it, but it seems like what you're looking for.
Whatever tool you try to use to do this will only hide some of the complexity or make your code C++-unlike and that will in turn make it harder for others to read/maintain.
I recommend that you just learn and get used to the compilation model of the language rather than fighting it. Deciding what goes into the header and/or the implementation is not an automated process, but rather part of the design and tools cannot design for you. Any automated tool to do that will end up generating a less than perfect result, probably longer compile times and/or leaking implementation details to the users of your headers.
Related
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 1 year ago.
Improve this question
pimpl idiom allows to reduce compilation dependencies in projects and have binary compatibility at the same time.
In other words you can change private implementation of a class without the need to recompile client's code.
Where can I find examples of such approach? Do you know any open source libraries or apps that uses it?
I know about QT and Poco:
D-Pointer - Qt Wiki
poco/IPAddress.h at develop · pocoproject/poco (but is this correct to include 'impl' header file in the 'public' header file? Any change in that private impl will cause recompilation).
Where can I find examples of such approach? Do you know any open
source libraries or apps that uses it?
Qt. Specific module example: QGraphicsItem.cpp, filled with d_ptr. Private part interface. The whole thing with both public and private modules.
A private implementation makes a lot of sense in case of porting the whole library/framework to a different platform. You just put a different files for implementation in while keeping the public interface as is. And the implementation is accessible via d_ptr->.
For the curious: non-Qt Pimpl C++ 11 example.
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 wanted to ask if anyone of you knows if there is a setting or plugin for Visual Studio 2015 Enterprise to automatically include any missing things, example if a namespace is missing or if "endl" is missing it includes the class.
Thanks!
I'm afraid not only can I not find / am not aware of such a plugin - I doubt it will ever exist.
The problem comes that without knowing every include file on your computer (which is a very time consuming/hard process), how could said plugin know which one you wanted?
Example:
I have marmalade (A cross platform development tool), Cygwin-Dev (A windows unix-shell), a GCC-cross compiler and visual-studio installed.
This means my computer has four (if not more) versions of "iostream", as well as several different implementations of the standard library (for different platforms).
How could such an add in know "which" include I wanted?
Personal opinion:
I understand what you are looking for, but honestly - even if such a tool did exist, I would advise against using it. when you get beyond simple example "hello world" programs and alike, C++ include files become a non-trivial subject. A single project I am involved in professionally has near two-thousand header-files, ranging from Iostream, though to third-party libraries, and near a thousand home-grown files.
Managing and understanding what to include and where is an essential skill of the C++ programmer, and quickly becomes second nature.
P.S.
Remember that every function on sites such as en.cppreference.com/w/ will state at the top of the page what header file you need to include them. Reading such reference pages will (also) become second nature in due time.
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 8 years ago.
Improve this question
Are there such tools? If so, what are they called, and is there a generic, searchable term? "Image size profiler" doesn't seem to yield many results. I'm not even certain how you would tag this.
I'm looking for something that would take a native .exe or .dll, and using the .pdb file, would help elucidate why a binary is several megabytes in file size by visualizing what is taking up the most space. Hopefully capable of analyzing static variables/tables, code, and resources, and preferably free if possible.
Do tools exist to do the analysis statically, or is running it under a memory profiler the only option? Is there a free memory profiler that would help with the file size itself?
I have done this manually on occasion, using a linker map file, which lists all the functions, their positions and lengths.
It would be nice if there were a tool to take 20 uniformly distributed "stabs" into the .exe or .dll and tell me the name of the function it lands in.
If I did this often enough I would write one.
However, a simple way to see what's accounting for most of the space is to simply look at the map file, in random locations, and see what functions are in there.
As an example of what I mean, I have seen files where large I/O classes, or Date classes, or container classes, were included just because there was one variable declared with such a class but not even used.
Or a local class could inherit from a general system class, causing tons of stuff to be linked in, when the local class doesn't actually need it.
This can be easily spotted by just eyeballing the map file.
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 need an open source tool (even a relatively primitive one will do) which performs Mutation Testing on C++ code. I require it to be open source as I require to modify it in a proof of concept experiment.
I tried Googling it but did not come up with open source tools, I came up with this question, but the suggested tools in the answers are either not open source or do not mutate C++.
I presume that by "C++ code" you mean something that mutates the source code itself rather than a compiled version? Source code mutation is far harder to implement than intermediate code mutation (e.g. Java bytecode or .NET IL). Because of this, I strongly suspect that you won't find an open source one.
The challenge is to parse the source code into some form of syntax tree, a hard problem in C++, which will then allow you to identify mutation points and make the source code changes you need. You might like to take a look at GCCXML as an open source starting point for parsing - adding the mutation is actually the more straightforward part of the problem.
The open source NinjaTurtles (disclaimer: I am lead developer on this) will mutate assemblies compiled from .NET managed C++ code, but I suspect that won't be any good to you?
Have you looked into the Clang rewriter engine or their AST matchers? You can search for certain spots in the source code semantically, then apply transformations and recompile. It was designed for generic source to source tools and analysis.
It's a bit roll your own, but I think it is definitely workable.
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 5 years ago.
Improve this question
I am porting a large, messy, 10 year old cold base in C++ from Metrowerks on OS X to XCode. There are so many files and all the other people that touched this over the years are gone. Nobody know what files are actually needed and which are just cruft.
Is there any tool that I could run and have it produce a list of what files are ACTUALLY needed?
You could run doxygen on your project and have it generate inheritance diagrams for your classes. It can also generate caller graphs to help you find dead code.
You can try searching this static code analyzer list in Wikipedia. The ones that I've seen in actions would be cppdep and Include Hierarchy Viewer, although the first one is a little rough and the latter is a Windows analyzer only for the include tree. Also that still might not give you all the info if the dependencies are not explicit.
Edit: Also, the following StackOverflow search query seems to have results that might interest you:
https://stackoverflow.com/search?q=c%2B%2B+dependency