int main(int argc, char** argv) {
uint numQueens = 8;
if(argc > 1) {
numQueens = atoi(argv[1]);
if(argc > 2) {
#define DEBUG
} // END if
} // END if
cout << numQueens << '\n';
#ifdef DEBUG
Board myBoard(numQueens, true);
#else
Board myBoard(numQueens);
#endif
return 0;
} // END main(argc, argv)
When I realized DEBUG would always be #define'd since it is a preprocessor directive. My question is, is there a simple way to do what I'm trying by passing an argument to the execution command as opposed to just adding #define DEBUG in the actual source?
Is there a way to do it that would maintain the conditional compilation? (No reason I actually need it just thought it would be a cool thing to learn how to do if its possible)
And you're correct, Board is a class I created and was trying the same concept (lines 5-7 of OP, except with the second arg for the Ctor) for debug print statements within it.
Generally I just use VS as my IDE, but it's on my desktop and I'm currently not able to access it.
My laptop runs Ubuntu and I just edit files in Sublime then compile w/g++, although I rarely use my laptop as a programming environment. Frankly, I'm new to Ubuntu and once I found and figured out how to install something that worked I just left it at that and haven't revisited the topic until now.
I will check out both of those, thank you for the recommendations!
#include <memory>
#include <string>
#include <cstdio>
// for demo purposes; could have directly used the deleter &std::close
void close_it( std::FILE* file ) { std::fclose( file ) ; }
int main()
{
auto p = std::make_shared<std::string>( "hello world" ) ;
auto p2 = p ;
std::weak_ptr<std::string> wp(p) ;
// examine p in the Visual Studio debugger by placing the cursor over it
// it would report:
// p shared_ptr "hello world" [2 strong refs, 1 weak ref] [make_shared] std::shared_ptr< std::basic_string<char...
std::shared_ptr<std::FILE> file( std::fopen( __FILE__, "r" ), &close_it ) ;
// examine file in the debugger by placing the cursor over it
// it would report:
// file shared_ptr {_Placeholder=0x0 } [1 strong ref] [custom deleter] std::shared_ptr<_iobuf>
// pull it down, and the deleter would be shown as:
// [deleter] <address> {test1.exe!close_it(struct _iobuf *)} std::_Compressed_pair<...
}
@JLBorges
I'll have to check this out whenever I get access to VS again (hopefully soon if I can figure out how to download VS Code via FurryGuys' post)
@FurryGuy
Whoa... Last I checked VS was only available via Wine on Ubuntu, and (as is the case with most things running through Wine that I've checked out) was quite buggy. A quick Google search proves me wrong, so I'll have to look into this! Is this only available for VS Code or the whole VS suite? I assume this excludes .NET but my experience w/C# (and anything in .NET) is rather limited.
> I'll have to check this out whenever I get access to VS again
> (hopefully soon if I can figure out how to download VS Code via FurryGuys' post)
You will have to check it out on windows.
VSCode uses GDB or LLDB as the debugging back-end; don't think that it has the complete set of debug visualisers.
Visualising components in the debugger is all about the debugger being aware of and understanding the implementation details of a compiler and the associated standard library.
As such, a C++ debugger does not require knowledge of 'ISO standard C++' . The standard allows a variety of different implementations; the debugger needs to know the specific implementation details.
For instance, the Visual Studio debugger works equally well with the LLVM front-end 'Clang With Microsoft CodeGen'. In other words the front-end deals with 'ISO standard C++' (in this particular case clang++ does), the debugger deals with the back-end (Microsoft CodeGen).