FAQs about vc7.0

Source: Internet
Author: User
1) Disable
# Pragma warning (Disable: 4311 4312) // the pointer type is forcibly converted and the size does not match completely.
Warning c4311: 'Type cast': pointer truncation from 'trinode * const' to 'Long'
Warning c4312: 'Type cast': conversion from 'unsigned int' to 'sac _ node_add * 'of greater size
Note: For 64-bit programming, the c4311 warning should be handled, and C412 may not.

# Pragma warning (Disable: 4244 4267) // data loss, 4244 for known type, 4267 for 64-bit type conversion
Warning c4244: '=': conversion from 'long' to 'Char ', possible loss of data
Warning c4267: '=': conversion from 'size _ t' to 'long', possible loss of data

# Pragma warning (Disable: 4996) // Security Warning
Warning c4996: 'fopen' was declared deprecated

2) msvcr80d. dll
There is a problem with the timestamp of the FAT32 file system, so there is no such problem in the NTFS partition.
Solution: in the editing status, click Project menu> property> Configuration Properties> Configuration tool and select "use FAT32 solution" on the right as "yes.

3) debugging Parameter options
A) set the row number: Tools> Options> text editor> C/C ++, and select display: line numbers.
B) Use a 10-digit number in the debugging variable: Right-click in the debugger window and remove the hexadecimal check box.
C) working path: Right-click the property page, General --> output directory on the project properties page;
D) executable program: Right-click the property page, debugging --> command on the project property page;
E) set the pre-compiled header file. symptom: Fatal error c1010: unexpected end of file while looking for precompiled header directive,
Solution: Right-click the CPP file, property page, C/C ++ --> precompiled headers in the project, select the first item, and do not use the pre-compiled header file;

4) debug the DLL
You cannot enter the source code of the DLL. The solution is as follows:
The first is clean --> rebuild; the second is to set the project dependency; otherwise, an error may occur due to comments of a file or other inexplicable causes, re-analyze the file to be accessed. It is best to restore it to the last page to see what caused the error.

5) 64-digit output
_ Int64 num1;
Printf ("% i64d", num1 );
In GCC, % ll can be used to directly obtain the 64-bit output. typedef long _ int64;
Note: The long data type is not supported in VC, and only the MS _ int64 can be used. The following are the unsigned, signed, and hexadecimal output formats of 64 in VC.
# Define host_widest_int_print_dec "% i64d"
# Define host_widest_int_print_unsigned "% i64u"
# Define host_widest_int_print_hex "0x % i64x"

6) How to redefine winsock2.h and windows. h
A) solution 1: Add a macro before Windows. h to define win32_lean_and_mean
# Define win32_lean_and_mean // This macro is used to accelerate the loading of windows. H. It can contain fewer header files.
# Include <windows. h>
B) solution 2: winsock2.h before Windows. h

7) How to Use the MFC Library? (Lightweight ).
Suppose: In a Windows console program, the string template class cstring of MFC will be used later, but there is no need to add too many other classes of MFC.
Method:
A) choose "use MFC in a share DLL" from the VC project menu> property> General> Use of MFC;
B) generate an stdafx. H. In this header file, only
# Include <afxwin. h> // MFC core and standard components
If the socket function is used
# Include <afxsock. h> // instead of <winsock2.h> <mswsock. h>
// Other structures or header files to be added...

8) Error
A) Pay attention to the life cycle of the variable. If you want to use the variable in the for and while statements, declare the variable before the statement;
B)

XX) file I/O considerations
A) file handle: number of file descriptors. The total number of file handles that can be opened by a process is limited. It is tested to be <1024 (System Limit). In addition, the process is disabled, all file handles opened by this process are automatically closed; file handles are reusable, and each obtained file handle must be the smallest unused; therefore, the same thread is continuously closed, the handle pointer may be the same, and the thread ID may be the same;
B) Io efficiency: It is recommended that the size of the buffsize be the same as that of the file block. For example, a common 8 K file system has the highest efficiency;
C) file sharing: the kernel maintains three data structures: entry table items, file table items, and file node structures. These three tables constitute the relationship between files and processes. it is also the key to understanding file read/write locks. Note that each process occupies a position in the process entry, and each process points to a process-related open file table entry, each file maintains a file node structure. therefore, the variables exclusive to each process are file descriptors, indicating the File status when the file is opened, and the current file offset. The file length, owner, device, the location pointer in the disk is the shared variable of each process.
D) file path: use./to represent the lower-level Directory, which can also be expressed by././is an escape character, indicating '/' to use '//'.
E) Locking skills: file-level, byte-level;

F) function usage tips:
Io without cache refers to the function called by the system: read, write, lseek, open, close...
Lseek. fseek only records the current file displacement in the kernel, and allows the file displacement to be greater than the file size, without causing Io operations. Therefore, this function usually does not have errors. lseek serves the next read/write function. to judge the file read/write function, fread and fwrite should be disabled if an error occurs. after each read/write operation, the displacement must be changed before the next operation can be performed. Otherwise, the operation is performed at the same position, unless the file is opened using the append method. (in other words, the offset must be located first for each write operation ).
Multiple processes can read the same file normally, because each process has its own file table items and has its own file displacement. However, if multiple processes write a file in the same way, errors may occur, therefore, we need to use lseek and write as an atomic operation. on Windows, threads and processes are equivalent in the kernel (?), Therefore, multi-process operations are similar to multithreading.

Faq1: multi-level pointer Initialization
A) Long * m_ltest1 = new long;
B) Long ** m_cppvalue1;
M_cppvalue1 = new long * [3];
For (I = 0; I <3; I ++) {m_cppvalue1 [I] = new long [m_lmaxdocid];}

C) Long *** m_cppvalue;
M_cppvalue = new long ** [m];
For (I = 0; I <m; I ++ ){
M_cppvalue [I] = new long * [N];
For (j = 0; j <n; j ++ ){
M_cppvalue [I] [J] = new long;
}
}
// The Order of releasing memory is the opposite. Delete the element space at the lowest layer first.
For (I = 0; I <m; I ++ ){
For (j = 0; j <n; j ++ ){
If (m_cppvalue [I] [J]) delete m_cppvalue [I] [J];
}
If (m_cppvalue [I]) delete m_cppvalue [I];
}
If (m_cppvalue) delete m_cppvalue;

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.