MSVC++ Tips
C++/C++ 2022. 1. 22. 21:02 |Multi-processor Compilation
Project Properties -> Configuration Properties -> C/C++ -> General -> Multi-processor Compilation -> Yes (/MP)
Security Check
Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Security Check -> Enable Security Check (/GS)
※ The Security Check helps detect stack-buffer over-runs, a common attempted attack upon a program's security. (/GS-, /GS)
※ 0xfdfdfdfd(No Mans Land)를 Write시 Exception?을 내뿜는 Debugging 기능.
- Debug Mode Only인듯...
- Release Mode에서는 0xcccccccc, 0xfdfdfdfd, 0xcdcdcdcd, 0xdddddddd 이런게 없음.
※ 0xcccccccc(Variable, 미개척지) -> 0xfdfdfdfd, 0xcdcdcdcd, 0xfdfdfdfd -> 0x00008123(Variable, In 64KB Barrier), 0xdddddddd, 0xdddddddd, 0xdddddddd
- 0xfdfdfdfd(No Mans Land)를 Write시, delete Operation에서 "HEAP CORRUPTION DETECTED"에러가 발생함.
- 0xcccccccc(Kernel Area)는 IO를 하면 "read access violation", "write access violation"이 발생함.
- 0xdddddddd는 Write를 해도 아무런 에러를 발생하지 않음.
Two-Phase name lookup 기능 사용(VC++2017)
Project Properties -> C/C++ -> Conformance mode(준수 모드) -> Yes (/Permissive-)
※ /permissive- enables two-phase name lookup in the C++ compiler. It is still work in progress, and doesn't currently work with OpenMP or C++/CLR modes.
※ Two phase lookup is for templates, and defines in no uncertain terms what method calls inside the template should and could call.
C++17 Usage On/Off(VC++2017)
Project Properties -> C/C++ -> C++ Language Standard(C++ 언어 표준) -> ISO C++17 Standard (/std:c++17)
Show Includes
Project Properties -> Configuration Properties -> C/C++ -> Advanced -> Show Includes -> Yes (/ShowIncludes)
※ Generates a list of include files with compiler output. (/showIncludes)
Use Full Paths
Project Properties -> Configuration Properties -> C/C++ -> Advanced -> Use Full Paths -> Yes (/FC)
※ Use full paths in diagnostic messages.
Partial PDB -> Full PDB
Project Properties -> Configuration Properties -> Linker -> Debugging -> Generate Full Program Database File -> Yes
※ ? 이놈은 디버깅시 무슨 영향을 줄까?
- Project Properties -> Configuration Properties -> Linker -> Debugging -> Generate Debug Info -> Optimize for debugging (/DEBUG) - VS2015
- Project Properties -> Configuration Properties -> Linker -> Debugging -> Generate Debug Info -> 공유 및 게시를 위해 최적화된 디버그 정보 생성(/DEBUG:FULL) - VS2017
※ Full PDB - This option generates a full PDB from a partial PDB generated when /Debug:fastlink is specified. Full PDB allows sharing the binary and the PDB with others.
※ 기본 MFC Project에서 PDB의 File Size는 Partial PDB: 2.5MB, Full PDB: 7MB 정도 됨.
Code Analysis
Project Properties -> Configuration Properties -> Code Analysis -> Enable Code Analysis on Build(빌드에 코드 분석 사용) -> Check
※ 디폴트는 꺼져 있음.
※ Compile-Time에 코드 분석을 수행함.
※ 이전에 FXCop이 코드 분석으로 도입된 것.
※ Nuget에서 FxCop 검색, 설치를 통해 Code Analysis Rule을 Update 할 수 있음.
PerfTips 색상 변경
Menu -> Tools -> Options -> Environment -> Fonts and Colors -> Show settings for: -> PerfTips
※ Debug Mode에서 우측 Elapsed Time Display하는 놈.
※ PerfTips는 고도의 Huristic Algorithm을 사용하여 Debugging, VS가 소모하는 시간을 최대한 배제하고 실제 코드가 소모한 시간만을 Display 하도록 개발됨.
Enable virtual space
Menu -> Tools -> Options -> Text Editor -> Enable virtual space
※ 공백을 클릭해도 커서가 그 공백에 위치가 가능하게 됨(원래는 그 행의 마지막 문자에 커서가 가는 것이 보통).
빈줄은 Ctrl + C, Ctrl + X 불가능케 하는 기능
Menu -> Tools -> Options -> Text Editor -> All Languages -> General -> Apply Cut or Copy commands to blank lines when ther is no selection
강화된 스크롤 바(Map Mode 가능)
Menu -> Tools -> Options -> Text Editor -> All Languages -> Scroll Bars
- Changes
- Bookmarks
- Break Points
- Errors
- Caret Position
Code Formatting
Menu -> Tools -> Options -> Text Editor -> C/C++ -> Formatting
※ Copy & Paste 할 때 Format을 부여할 수 있음.
Diagnostic Tools On/Off
Menu -> Tools -> Options -> Debugging -> Enable Diagnostic Tools while debugging
PerfTip On/Off
Menu -> Tools -> Options -> Debugging -> Show elapsed time PerfTip while debugging
Edit and Continue On/Off
Menu -> Tools -> Options -> Debugging -> Enable Edit and Continue
Debugging Tips
※ Immediate Window에서 std::vector<int> object의 값들을 보거나 설정할 수 있음.
※ 주석에서 변수를 형 변환해서 보기 가능함.
// (DataContext *)pContext // pContext를 DataContext *형으로 캐스팅 하여 내용을 봄.
// (int *)args, 10 // int 배열인데 Element가 총 10개임.
@err, hr
@env
※ 'Step Into Specific' Context Menu 有
- Current 실행 흐름에서 Step Into를 해야 하는데 여럿 가운데 하나를 선택해 Step Into하여 들어갈 수 있음.
Compiler Tips
Constexpr의 Compile-Time Depth와 Steps를 줄 수 있음.
- Project - Properties - Configuration Properties - C/C++ - Command Line - Additional Options
- /constexpr:depth 1000000
- /constexpr:steps 1000000
C++ Compiler Version Check
_MSVC_LANG
Enable mouse click to perform Go to Definition
Tools -> Options -> Text Editor -> General -> Enable mouse click to perform Go to Definition
Edit.SelectCurrentWord
Tools -> Options -> Environment -> Keyboard -> Edit.SelectCurrentWord -> Ctrl + W
Turn off green lines
Tools -> Options -> Text Editor -> C/C++ -> Advanced -> Code Analysis -> Disable C++ Code Analysis Experience
출처 - http://tegtips.blogspot.com/2019/10/turn-off-green-lines-visual-studio.html
Turn off green lines Visual Studio
When you open a C/C++ project in Visual Studio 2019, a lot of green lines (squiggles) appear. This can be turned off: Options->Text Editor...
tegtips.blogspot.com
'C++ > C++' 카테고리의 다른 글
멤버 함수 포인터(Member Function Pointer) (0) | 2022.02.11 |
---|---|
(작성 중) Scoped static 과 Singleton (0) | 2022.02.02 |
MSVC 컴파일러 전용 XML 주석 (0) | 2022.01.12 |
문자열 쪼개기 Split (0) | 2021.12.31 |
using 의 쓰임새 (0) | 2021.12.25 |