Tag Archives: C

C + + pauses the black window system (“pause”); (get ch(), getchar(), system (pause)’s connection and difference

In a c++ program, if it is a window, sometimes it will disappear with a flash. If you don’t want it to disappear, add:

system(“pause”);

Note: Do not add after the return statement, it will not be executed.

Analysis:

System () is a call to the system command;

pause pause command;

When run here, it will say “Press any key to continue…” or “Press any key to continue…” ;

In VS2008, can be called directly

VC 6.0, to add the following header file!

#include < stdlib.h>  
The

Supplement: http://bbs.csdn.net/topics/390231844

http://www.gidnetwork.com/b-61.html (the answer), 9/f,

1:

I don’t know why I often see people declare “void main” on CSDN

is not a standard entry point for C++

standard supports only two kinds of announcements

first type “int main”

int main(int argc, char *argv[]))

declares “void main” may have unexpected results

this doesn’t just apply to C++, C works as well

is this the textbook’s fault?Or is it the professors’ fault?

2:

do not use system(“pause”) to pause. Use STD ::cin. Get or getchar() instead.

why don’t you use system(“pause”)?

for two reasons

1: not portable
Two: it’s very expensive

where is it important?Let’s look at the process of system(“pause”)

1: pause your program

2: start the OS in the sub-process

3: finds the command to execute and allocates the memory for it

4: wait for input

5: recycle memory

6: end OS

7: continue your program

Getch () :
header file: conio. H
function purpose: read a character from the console, but not displayed on the screen
e.g. :
char ch; Or int ch;
getch (); Or ch = getch ();
with getch (); It waits for you to press any key before continuing with the following statement;
with ch = getch (); It waits for you to press any key, assigns the ASCII character to ch, and then executes the following statement.

getchar():
Extract characters from IO stream!
this function is declared in the stdio.h header file and used to include the stdio.h header file. Such as:
# include< stdio.h>
int getchar (void);
getch has the same basic functions as getchar, except that getch gets the key value directly from the keyboard and does not wait for the user to press enter. As soon as the user presses a key,
getch returns immediately. Getch returns the ASCII code entered by the user and returns -1 on error. The
getch function is commonly used in program debugging. During debugging, the relevant results are displayed in a critical position for viewing, and then the getch function is used to pause the program,
when any key is pressed after the program continues to run.

the first is that the two functions exist in different header files, this one basically you write #include< stdio.h> Getchar (), can accept a character, press enter to end, and display on the screen, and can clear forward just write
2. Getch (), receive a character, on the screen does not show
you write more, practice should be understood
Getchar () gets a character from the input device that is displayed on the screen, getch gets a character from the input device,
but the character is not displayed on the screen, for example:
#include < stdio.h>
int main()
{
printf(“%c”,getchar()); Suppose you get a character f from the keyboard here and press enter and you’ll see something like this
f
f
the first f is the f that you typed in, the second f is the f that printf gets
#include < stdio.h>

int main () {
printf (” % c “, getchar ());
}
suppose you enter an f and the result is
f this f is the printf output f
getchar is optimized,
getchar input character, until you press enter, then execute the code
getch without hitting enter
System (“pause”) can freeze the screen to observe the execution results of the program.
getch can not only pause the program
but also get a character
system(“pause”) is just a simple pause
the difference is the mechanism of action, although the effect looks the same. The
system return value is the result after you call the Shell command, and the getch() function will return the result provided by the function.
usually, the return value of Shell command may be unexpected and uncertain. Sometimes, it is impossible to judge whether the command
is executed successfully through the return value, which will have an impact on the program that conducts subsequent processing according to the return value. The return value of the function determines whether the
line is held successfully. But you don’t judge the return value at all, and you don’t process it, so you don’t have to worry about these differences.

How to solve fatal error C1010!

 

in compiled VC++6.0 is, appears

fatal error C1010: unexpected end of file while looking for precompiled header directive

problem explanation in detail:

fatal error C1010, the file did not end as expected while looking for a precompiled indication header file. The header file where the precompiled indication information was not found.

problems generally occur in:

adds some CPP files to an MFC program by adding files, but the CPP file is not MFC, is standard C++.

solution 1:

, right-click the CPP file in the Project Project and set it to the first item: Not using preheaders, from the C++ Header on the Project Settings page.

solution 2:
Add the include file stdafx.h at the beginning of the.cpp file.

# include “stdafx. H”

from: MSDN

Visual C++ Concepts: Building A C/C++ Program

Fatal Error C1070

mismatched #if/#endif pair in file ‘filename
An #if, #ifdef, or #ifndef directive has no corresponding #endif. The following sample generates C1070:

// C1070.cpp
#define TEST

#ifdef TEST
// use the line below to resolve the error
// #endif

#ifdef TEST

#endif

int main() {
}
// C1070

Error 1606 could not access network location% SystemDrive% / inetpub / wwwroot /

Prompt for title error when uninstalling or reinstalling Infragistics NetAdvantage
Under Windows 7
1. Open registry Regedit
2, find the HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/InetStp PathWWWRoot
64-bit operating system: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\InetStp\PathWWWRoot
% SystemDrive %/inetpub/below/= = “C: \ inetpub \ below
 

 
 
 
 

Utraiso recording DVD application area failed power calibration area error


Originally was to burn a RHEL 6.0 system disk, did not expect out of this problem.
As shown in figure:
(UtraISO version 9.5)


Asked the teacher, Google’s answer is as follows: I test \ to describe the following
1, the DVD drive a, how can not burn function, DVD all don’t know how do
2, incompatible, as stated in a b
3, burner is broken c, obviously is normal
4, do not support high-speed write, reduce the speed try D, no
5, head aging e, impossible
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — I explore solutions — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
Solutions:
1, select the ISO file to be burned –& GT; 2, right – button –& GT; 3. Opening mode –& GT; 4, UltraISO Premium — — — — — — — — — — – & gt; 5. Always open the file using a selected program –& GT; 6. Yes.
Note: In step 5, always check the box before “Always use the selected program to open such files.”


Start burning normally… Drops drops…


Ok, burn successfully.

The author’s blog: http://blog.csdn.net/yytry8

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — – but — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — line — — — — — — — — — — — — — — — — — — — — — — — — — — —

Visual Studio Tips: error LNK2005: … already defined in LIBCMTD.lib(new.obj)

Problems encountered

A very old C++ project, before the compilation was all right, just after I introduced a few new.h and.cpp files, the compilation failed to pass, reported the following error:
(On the premise, of course, that there is no problem with the new files I introduced being double-checked, otherwise I would have started with those files and there would have been no article.)

Error	2	error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)	
C:\Work\Demo\DemoApplication\nafxcwd.lib(afxmem.obj)	Sentinel-XP



1>------ Build started: Project: DemoApplication, Configuration: Debug Win32 ------
1>  text.cpp
1>gbk.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
1>nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
1>nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
1>nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj)
1>Debug\DemoApplication.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Problem analysis

There is no such thing as a gratuitous compilation error. After an extensive search, there is an explanation on MSDN that I think is very good. Here is an excerpt:

The CRT libraries use weak external linkage for the new, delete, and DllMain functions. The MFC libraries also contain new, delete, and DllMain functions. These functions require the MFC libraries to be linked before the CRT library is linked. 

I will not translate it into Chinese, I am lazy, and I believe everyone can understand this sentence.

This way, we give the MSDN link: https://support.microsoft.com/en-us/kb/148652

To solve the problem
In this article on the MSDN: https://msdn.microsoft.com/en-us/library/72zdcz6f.aspx
The following sentence was given:

To fix, add /FORCE:MULTIPLE to the linker command line options, and make sure that ... is the first library referenced.

is just like this:

Then it was compiled. Although there were some warnings, the compilation passed:

1>------ Build started: Project: DemoApplication, Configuration: Debug Win32 ------
1>  ...
1>  ...
1>  Compiling...
1>  ...
1>  Generating Code...
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
1>gbk.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
1>nafxcwd.lib(afxmem.obj) : warning LNK4006: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj); second definition ignored
1>nafxcwd.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj); second definition ignored
1>nafxcwd.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj); second definition ignored
1>Debug\DemoApplication.exe : warning LNK4088: image being generated due to /FORCE option; image may not run
1>  DemoApplication.vcxproj -> C:\Work\Demo\DemoApplication\Debug\DemoApplication.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

works fine.

Of course, this is not the root of the problem, but given the old project document, I can’t easily change it too much, so let’s leave it as an imperfect solution.

reference

A LNK2005 error occurs when the CRT library and the MFC libraries are linked in the wrong order in Visual c + + https://support.microsoft.com/en-us/kb/148652
would Tools error LNK2005 https://msdn.microsoft.com/en-us/library/72zdcz6f.aspx
selectany https://msdn.microsoft.com/en-us/library/5tkz6s71 (v = versus 80). Aspx
LNK2005, “Already defined error” would error in MSVC2010 http://stackoverflow.com/questions/8343303/lnk2005-already-defined-error-linker-error-in-msvc2010

Error c2143: syntax error: missing ‘;’ before ‘type’

When using VC6.0 to compile. C file, if you define variables in any place in the program, the above error will occur;
Reason: Generally in ANSI C or C++, it is allowed to define variables at any time in executable code, but in K& It’s not allowed in R and C, and that’s why we have this error. VC6.0, VS2008 are used K& R C to implement the C language, so the compilation process will report errors.
In pure C, variable declarations for a block of code are usually at the front end.
Solution: 1. Put all variable declarations at the beginning.
2. Save the file as. CPP file.
 
 

Error: current transaction is aborted, commands ignored until end of transaction blockp

In normal database programming, we encountered errors from time to time: Current Transaction is aborted, commands ignored until the end of transaction BlockP. How to solve it?We usually look it up on the Internet. If you’re a little bit better at English you can tell from the error message that there’s probably something wrong there. But if the experience is not very rich, or the Internet to find more convenient. The most basic error message can see from the official documentation (http://www.postgresql.org/docs/8.4/interactive/errcodes-appendix.html).
The error above is the cause of improper transaction control, which can be written as follows.
Improper writing 1:
Connection OPEN.
Try {
Try {
Database operation A.
} Catch (Exception e) {
The log. The error (” do something “);
}
 
Database operation B. // The above error may occur during this data operation.
The transaction commits commit.
} Catch (Exception ex) {
Transaction rollback rollback.
} the finally {
Close the connection.
}
 
Improper writing method 2:
Connection OPEN.
Try {
Database operation A.
Database operation B.
The transaction commits commit.
} Catch (Exception ex) {
Database operation C. // The above error may occur during this data operation.
The transaction commits commit.
} the finally {
Close the connection.
}
 
In a Postgres database, if there is an error in a database operation in the same transaction, all subsequent databases in that transaction will fail.
If there is an error in database operation A, the same database operation B will report an error when it is executed. If there is an error in database operation A or database operation B, the same database operation C will report an error.
To avoid errors, someone is using the re-open method, which in effect throws away all previous operations (not in the case of auto-commit) and adds overhead by re-opening, which is not recommended.
Depending on the cause of the error, we can treat the processing before the possible error as a transaction. The processing after the error is then treated as a transaction, depending on the specific logic. That way you can avoid making mistakes.
In this way, we can change the improper 1 to
Try {
Database operation A.
} Catch (Exception e) {
Transaction rollback or commit;
The log. The error (” do something “);
}
Database operation B.  
 
In this way we can change the improper notation 2 to
} Catch (Exception ex) {
Transaction rollback or commit;
Database operation C.   
The transaction commits commit.
} the finally {
Close the connection.
}
 
 
 

Workaround: windowserror: [error 193]% 1 is not a valid Win32 Application

WindowsError: [Error 193] %1 is not an valid Win32 application

Specific solutions:

This is because your computer is 64-bit

But your file is 32-bit, so you have this conflict

By this point, you should know that you have deleted the 32-bit Python download

There’s a similar answer on StackOverflow, you can click on it and see

Python Download interface portal, click to access

Python3 is best downloaded

Python 3.5.4 rc1-2017-07-25
Download Windows x86 executable installer

Python2 is best downloaded

Python 2.7.14 rc1-2017-08-27
Download Windows x86 MSI installer

Afterword.
Finally, the old formula, publicity a wave of their own public number! (Attention!)
I in the big house, welcome everyone to pay attention, please sweep the following two-dimensional code (‘ ▽ ‘ ‘”)

If you feel helpful, you can scan the code, praise and encourage! Thank you very much!

Solution windowserror: [error 193]% 1 is not a valid Win32 Application

WindowsError: [Error 193] %1 is not an valid Win32 application

Specific solutions:

This is because your computer is 64-bit

But your file is 32-bit, so you have this conflict

By this point, you should know that you have deleted the 32-bit Python download

There’s a similar answer on StackOverflow, you can click on it and see

Python Download interface portal, click to access

Python3 is best downloaded

Python 3.5.4 rc1-2017-07-25
Download Windows x86 executable installer

Python2 is best downloaded

Python 2.7.14 rc1-2017-08-27
Download Windows x86 MSI installer

Afterword.
Finally, the old formula, publicity a wave of their own public number! (Attention!)
I in the big house, welcome everyone to pay attention, please sweep the following two-dimensional code (‘ ▽ ‘ ‘”)

If you feel helpful, you can scan the code, praise and encourage! Thank you very much!

C programming interface of SQLite database (6) result codes and error codes

SQlite database C programming interface (VI) Result Codes and Error Codes by QQ: 253786989 2012-02-07

Standard Codes
Here are the standard return values and error code definitions:

#define SQLITE_OK           0   /* Successful result */
/* beginning-of-error-codes */
#define SQLITE_ERROR        1   /* SQL error or missing database */
#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
#define SQLITE_PERM         3   /* Access permission denied */
#define SQLITE_ABORT        4   /* Callback routine requested an abort */
#define SQLITE_BUSY         5   /* The database file is locked */
#define SQLITE_LOCKED       6   /* A table in the database is locked */
#define SQLITE_NOMEM        7   /* A malloc() failed */
#define SQLITE_READONLY     8   /* Attempt to write a readonly database */
#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
#define SQLITE_CORRUPT     11   /* The database disk image is malformed */
#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */
#define SQLITE_FULL        13   /* Insertion failed because database is full */
#define SQLITE_CANTOPEN    14   /* Unable to open the database file */
#define SQLITE_PROTOCOL    15   /* Database lock protocol error */
#define SQLITE_EMPTY       16   /* Database is empty */
#define SQLITE_SCHEMA      17   /* The database schema changed */
#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
#define SQLITE_MISMATCH    20   /* Data type mismatch */
#define SQLITE_MISUSE      21   /* Library used incorrectly */
#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
#define SQLITE_AUTH        23   /* Authorization denied */
#define SQLITE_FORMAT      24   /* Auxiliary database format error */
#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
#define SQLITE_NOTADB      26   /* File opened that is not a database file */
#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
/* end-of-error-codes */

Some of these constants are returned only by a specific function, such as the SQLITE_RANGE, which is returned only by the SQlite3_bind_xxx function. Some constants, such as SQLITE_ERROR, only indicate that an error occurred during the execution of the function, but there is no way to know why the error occurred.
Sqlite_false stands for MISUSE of apis. For example, a bind function returns SQlite_ern when a statement is given another parameter after the sqlite3_step function has executed without being reset.
Extended Codes
Standard error codes provide less information about the cause of the error. So sometimes we use extended error codes. The extended error code is based on the standard error code, whose lower order byte is the original standard error code, and then attaches information to its higher order byte “or” to describe the details of the error.

int sqlite3_extended_result_codes(sqlite3*, int onoff);

The error codes for these extensions are not enabled by default due to compatibility issues with the client’s legacy programs. Programmers can enable or disable extended error codes by using the SQlite3_extended_result_CODES function.
Here are all the extended error codes (most of which describe SQLITE_IOERR) :

#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))
#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))
#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))
#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))
#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))
#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))
#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))
#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))
#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))
#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))
#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))
#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))
#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))
#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))
#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))
#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))
#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))
#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))
#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))
#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))
#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))

Error Functions

int sqlite3_extended_result_codes(sqlite3*, int onoff);

Enable or disable the use of extended error codes for a database connection. Enable extended error codes by passing a non-zero value to the second parameter of the SQlite3_extended_result_CODES function. This function always returns SQLITE_OK, and there is no way to get an extension error code that is currently enabled or off.

int sqlite3_errcode(sqlite3 *db);

If a database function operation does not return SQLITE_OK, you can then call the function to get the error code. By default it returns the standard error code, and it may also return an extended error code if the current database connection is enabled.

int sqlite3_extended_errcode(sqlite3 *db);

Similar to the SQlite3_errcode function, except that it only returns the extended error code.

const char *sqlite3_errmsg(sqlite3*);
const void *sqlite3_errmsg16(sqlite3*);

Returns an error code string, encoded in UTF-8 or UTF-16. Programmers should either call these functions, get the error code information, or make a copy. The next database operation may invalidate the returned string pointer.
SQlite error handling cannot handle multiple errors simultaneously. For example, if an API function call goes awrong and the programmer fails to check for that error, the next API function call may well return SQlite_ern, indicating that the program is trying to use an invalid data structure. So programmers should check and handle any errors that might occur after each API function call.
In addition, if multiple threads share the same database connection, it is best to encapsulate the core API calls and error-handling code in the Critical section. Programmers can use the SQlite3_db_mutex function to get the mutex pointer to the database connection (a pointer to the SQlite3_mutex object).
Prepare for V2 Version
The following table compares the prepare function of the original version with that of v2 version:

The V2 version of prepare is more concise for error handling and has the schema advantages listed in the table above, so it is recommended to use the V2 version of prepare.
Transactions and Errors
Typically, SQlite operations are in auto-commit mode. SQlite automatically encapsulates each SQL command into a transaction. Error recovery is easy if each statement is encapsulated in its own transaction. Any time SQLite finds itself in the wrong state, it simply rolls back the current transaction. This effectively cancels the current SQL command and returns the database to the state it was in before the error occurred.
However, once the BEGIN TRANSACTION command is executed, SQlite is no longer in autocommit mode. A TRANSACTION is opened and will remain open until either the END TRANSACTION or the COMMIT TRANSACTION command is executed. This allows multiple SQL commands to be encapsulated into a single transaction, allowing a discrete set of commands to execute either all or none (atomic operations), but it also limits SQLite’s error recovery.
When a displayed (explicit) transaction encounters an error during execution, SQLite attempts to cancel the statement just executed. Unfortunately, this is not always possible. If things go badly, SOMETIMES SQlite can just roll back the entire current transaction, with no other option.
The most likely errors to cause a rollback are SQLITE_FULL (database or disk space is full), SQLITE_IOERR (disk IO error or file is locked), SQLITE_BUSY (database lock), SQLITE_NOMEM (out of memory), SQLITE_INTERRUPT (interrupt). If the program is executing a display transaction and receives one of these errors, be prepared to handle the possibility of a transaction being rolled back.

int sqlite3_get_autocommit(sqlite3*);

With this function, you can get the current commit status. If a non-zero value is returned, the database is in auto-commit (atutoconmit) mode. If 0 is returned, the database is currently inside an explicit transaction.
If the SQlite database is forced to do a full transaction rollback, the database will once again go into transaction autocommit mode. If the database is not in auto-commit mode, it must be in a transaction, indicating that no rollback is required.

SQlite database C programming interface (VI) Result Codes and Error Codes by QQ: 253786989 2012-02-07

Error c2061: syntax error: identifier ‘this_ FILE’





… error C2061: syntax error : identifier ‘THIS_FILE’
… /new(35) : error C2091: function returns function
… /new(35) : error C2809: ‘operator new’ has no formal parameters
… /new(36) : error C2061: syntax error : identifier ‘THIS_FILE’
… /new(37) : error C2091: function returns function
very strange, yesterday this class has been tested, no problem, look up the Internet, finally found the problem.
Solutions:

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__!
#endif
#include “selectserver. h”
search, found these errors were related to the STL header file and VC6 generated in the CPP file, the STL header file is the following lines:
#pragma warning (disable:4786)
#include < list>
using namespace std;
The lines of code generated by VC6 in the CPP file are the following:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
STL header file to be written in the VC6 generated in the CPP file a few lines of code, remember! My “selectServer.h” file contains the STL header, so when you include” selectServer.h “in any other CPP file, be sure to include the #include” selectServer.h” in front of the lines of code that VC6 generates! So let’s change it to the following so that it compiles.
#include “SelectServer.h”
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
Conclusion in
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
Do not write #include after the introduction file error-prone move #include statements to the front of the paragraph