C/C ++: some easy-to-Forget knowledge points (continuously supplemented)

Source: Internet
Author: User

1. The default parameter cannot be used for C functions.

 

2. How does VC view the error message (getlasterror () in the debugging status ())

Generally, you can use getlasterror () to get the error number and then use formatmessage (...) to get the error description.

Here is a more direct method: Add @ err, HR in the watch window

 

3. Compile Win32 applications in VC without relying on the msvc Runtime Library: ensure that the application (exe) and Libraries (Lib, DLL, etc.) included in the application) all are compiled under MTD (Debug) or MT (release. How to Set in VC: Project-> properties-> Configuration properties-> C/C ++-> code generation-> Runtime Library-> multithreading (/MTD) (Under Debug) or multiple threads (/mt) (Under release ).

 

4. In VC attribute settings, choose Project> Properties> Configuration Properties> linker> display progress> display certain progress messages (/verbose: Lib ), in this way, you can see the link sequence in the output window during the compilation of the link program, which is helpful for handling errors reported by some duplicate libraries.

 

5. Repeated definitions in Win32 network programming. For example:

Error c2011: "fd_set": "struct" type redefinition

Error c2011: "timeval": "struct" type redefinition
This is because the header file is contained multiple times,

By default, windows. H will contain Winsock. H. When you include winsock2.h, it will conflict. Therefore, you need to define a macro before including windows. h to remove Winsock. h.

Add the following code:
# Define win32_lean_and_mean

# Include <windows. h>

 

6. inline functions: these functions are replaced by the memory space in exchange for execution time. They can be used to write inline functions for some frequently-needed functions (such as tool functions) to speed up calling. Considerations for inline functions: loop statements and switch statements are not allowed. inline functions must contain the function body to define inline functions.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.