用C++写uefi程序
来源:互联网 发布:html进销存源码 编辑:程序博客网 时间:2024/06/16 07:15
uefi编程多半是以C语言进行开发,要想使用类和模板要在cpp文件中以如下方式包含头文件
#ifdef __cplusplus
extern "C"{
#endif
#include <uefi.h>
#include <library/uefilib.h>
#include <library/basememorylib.h>
#include <Library/MemoryAllocationLib.h>
#include <library/uefiapplicationentrypoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <library/baselib.h>
#include <library/printlib.h>
//#include <typeinfo>
#ifdef __cplusplus
}
#endif
并定义NULL
#undef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((VOID*)0)
#endif
然后为了消除bool类型的警告要在inf文件中的[BuildOptions] 模块中加上
MSFT:*_*_*_CC_FLAGS = /wd4804
然后就可以写如下代码
class TestClass
{
public:
TestClass(){Print((CHAR16*)L"hello world c plus plus \r\n");}
~TestClass(){Print((CHAR16*)L"bye bye !!!");}
};
//typeid操作符的返回结果是名为type_info的标准库类型的对象的引用
template<typename type1, typename type2>
void TestTemplate(type1 a, type2 b)
{
Print((CHAR16*)L"size of first arg is %d size of second arg is %d \r\n", sizeof(a), sizeof(b));
}
EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable)
{
CHAR16 Msg[100];
UnicodeSPrint(Msg, 100, (CHAR16*)L"hello world \r\n");
Print(Msg);
TestClass t;
UINT32 a = 1;
CHAR16 *b = NULL;
TestTemplate(a, b);
return EFI_SUCCESS;
}
这样个还不支持new和delete操作。。
- 用C++写uefi程序
- 用C写SOAP程序
- 用emacs写C程序
- UEFI的helloworld程序
- 我用C写的打字程序
- 用C写的邮件发送程序
- 用C写一个自动关机程序
- [转]用 C/C++ 写 CGI 程序
- 用C写CGI程序简要指南
- 用 C/C++ 写 CGI 程序
- 用 c 写 CGI 程序简要指南
- 用c写CGI 程序简要指南
- 用C写CGI程序简要指南
- 用C写的汉诺塔(hanoi)程序
- 用C++写多线程程序
- 用C写的汉诺塔(hanoi)程序
- 用C写CGI程序简要指南
- 用 c 写 CGI 程序简要指南
- 关于C++函数思考2(C++函数返回引用和返回非引用的区别)
- RIP路由协议
- ASP.NET MVC3 利用滚动条加载数据
- Delphi程序调试简介 转载
- iOS开发UI高级—37Quartz2D(自定义UIImageView控件)
- 用C++写uefi程序
- hdu1520
- C#之玩转反射
- iOS开发UI高级—38Quartz2D使用(绘制基本图形)
- Java Note - Controlling Execution
- nyoj36
- HDU 1398
- 【牛腩】后台代码完结总结
- C++ 调用system()函数的多命令合并