Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Questions/C++

I'm a hobbyist developer and have a background with Java (IDE of choice was Eclipse). I'm using Visual Studio Express 2010 and wanting to learn C++.

Few questions:

  • I create a "HelloWorld" in C++ and compiles/runs in VS/Windows. When I try to compile it under Linux/GCC, it obviously throws tons of errors. Default windows console project includes windows specific files; but if just create an "Empty Project" it throws tons of linker/build errors. What's the best practices here to keep my code portable?

  • Why is it creating 47 files for 8 lines of code?

  • How do you format code? You can do Edit->Format Selection, but the hotkeys don't work?

  • How do I output to VS's 'Output' Window? ( like eclipse does when you run a console java app )

  • It keeps reverting my "Project Location" to my "home directory" every time I restart. How do you change it? Is it a bug? Because it's Express edition?

  • Is there a way to keep it from switching to Debug view when it runs?

like image 334
user697111 Avatar asked Mar 18 '26 21:03

user697111


1 Answers

I create a "HelloWorld" in C++ and compiles/runs in VS/Windows. When I try to compile it under Linux/GCC, it obviously throws tons of errors. Default windows console project includes windows specific files; but if just create an "Empty Project" it throws tons of linker/build errors. What's the best practices here to keep my code portable?

For portable code, avoid VS wizards entirely. Use Make/NMake if you're starting with rocks and sticks, or the portable build system of your preference (Ant, CMake, etc.) Some of these will spit out a VS solution/project file for you to use.

Why is it creating 47 files for 8 lines of code?

Wizards are magical like that.

How do you format code? You can do Edit->Format Selection, but the hotkeys don't work?

Ctrl-K Ctrl-F (under Edit, Advanced)

How do I output to VS's 'Output' Window? ( like eclipse does when you run a console java app )

Lookup OutputDebugString() for the debug window. Output window should get all cout/cerr output.

It keeps reverting my "Project Location" to my "home directory" every time I restart. How do you change it? Is it a bug? Because it's Express edition?

Probably hidden in options somewhere - don't know that one, sorry.

Is there a way to keep it from switching to Debug view when it runs?

Launch using Ctrl+F5 to run without the debugger attached.

Have fun!

like image 183
holtavolt Avatar answered Mar 21 '26 13:03

holtavolt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!