Yjx_driver_024_ C and C + + code differences in driver code

Source: Internet
Author: User

1.

C and C + + code differences in driver code
A, function calling convention
B, C, and C + + compilation Methods
C. Compile driver in C + + mode
D, C code upgrade to C + +
E, optimize the code for lesson 21

This lesson is mainly to do two work: "D, C code upgrade to C + +", "E, optimize the code of 21 Lessons"

"180" Copy the code from lesson 21st.

2.
*.c
The compiler will compile with the C compiler when the file suffix name is *.c
*.cpp
When the file suffix name is *.cpp, the compiler will compile in C + + compiler mode
Difference:

Solutions
add extern "C" before a function that requires C-mode compilation

The header files that need to be compiled in C are modified as follows
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include <NTDDK.h>//This contains header files that need to be compiled in C
#ifdef __cplusplus
}
#endif

1>errors in directory g:\ driver tutorial \024_ C and C + + code differences in driver code \MINI_DDK
1>mini_ddk.obj:error lnk2001:unresolved external symbol "struct _servicedescriptortable * keservicedescriptortable ([email Protected]@[email protected]@a)
1>bufferoverflowk.lib (gs_support.obj): Error lnk2019:unresolved external symbol [email protected] referenced in Func tion [email protected]
1>sys\i386\ddk_helloworld.sys:error Lnk1120:2 unresolved externals
[Email protected]@[email protected]@[email protected]@@z

[Email protected]//Request format
[Email protected]@[email protected]@[email protected]@@z?
Instance modification 21 Lesson code upgrade to C + + compilation mode
A, add extern "C" for the entry function
B. Modify the source file
C, modify the 21 lesson bug


extern "C" __declspec (naked) __stdcall Test (int a, int b)

Yjx_driver_024_ C and C + + code differences in driver code

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.