关于C++上的一些错误
About some errors on C++
我想编译一个php代码到dll,我是这个创建东西的新手,但我需要这个文件是dll。
以下是我需要编译到dll的代码:
#include "Stdafx.h"
#include "Post.h"
void DataSendAll(unsigned char* Packet, int Length)
{
for (int i=6400; i<7400; i++)
if(gObjIsConnected(i))
DataSend(i, Packet, Length);
}
void SendPost(int wId, LPCSTR Command, LPCSTR Text)
{
if (IsPost != 1) return;
if (!gObjIsConnected(wId)) return;
if (!strcmpi(Command, "/Post"))
{
MessageOutput(wId, "[%s] Useage: /Post <Msg>.", szPrefix);
MessageOutput(wId, "[%s] Price for post: %d, Minimun Level: %d", szPrefix, PostCost,
`PostLevel);
return;
}
gObj_SetInfo(wId);
if (gObj.Level < PostLevel)
{
MessageOutput(wId, "[%s] You're level is too low to post!", szPrefix);
return;
}
if (gObj.Money < PostCost)
{
MessageOutput(wId, "[%s] You don't have enough money to post!", szPrefix);
return;
}
BYTE *Packet;
char Message[100];
Packet = (BYTE*) malloc(200);
memset(Packet, 0x00, 200);
*Packet = 0xC1;
*(Packet+2) = 0x00;
memcpy((Packet+3), gObj.Nick, strlen(gObj.Nick));
sprintf(Message, "@@[Global] %s", Text);
memcpy((Packet+13), Message, strlen(Message));
int Len = (strlen(Message) + 0x13);
*(Packet+1) = Len;
DataSendAll(Packet, Len);
int Amount = (gObj.Money - PostCost);
gObj_Write(wId, gObj_Money, Amount);
MoneySend(wId, Amount);
free (Packet);
}
但当我尝试构建时,它给了我这样的错误
------ Build started: Project: Post, Configuration: Debug Win32 ------
Compiling...
Post.cpp
.Post.cpp(6) : error C3861: 'gObjIsConnected': identifier not found
.Post.cpp(7) : error C3861: 'DataSend': identifier not found
.Post.cpp(10) : error C2061: syntax error : identifier 'LPCSTR'
.Post.cpp(12) : error C2065: 'IsPost' : undeclared identifier
.Post.cpp(13) : error C3861: 'gObjIsConnected': identifier not found
.Post.cpp(14) : error C2065: 'Command' : undeclared identifier
.Post.cpp(14) : error C3861: 'strcmpi': identifier not found
.Post.cpp(16) : error C2065: 'szPrefix' : undeclared identifier
.Post.cpp(16) : error C3861: 'MessageOutput': identifier not found
.Post.cpp(17) : error C2065: 'szPrefix' : undeclared identifier
.Post.cpp(17) : error C2065: 'PostCost' : undeclared identifier
.Post.cpp(17) : error C2065: 'PostLevel' : undeclared identifier
.Post.cpp(17) : error C3861: 'MessageOutput': identifier not found
.Post.cpp(20) : error C3861: 'gObj_SetInfo': identifier not found
.Post.cpp(21) : error C2065: 'gObj' : undeclared identifier
.Post.cpp(21) : error C2228: left of '.Level' must have class/struct/union
type is ''unknown-type''
.Post.cpp(21) : error C2065: 'PostLevel' : undeclared identifier
.Post.cpp(23) : error C2065: 'szPrefix' : undeclared identifier
.Post.cpp(23) : error C3861: 'MessageOutput': identifier not found
.Post.cpp(26) : error C2065: 'gObj' : undeclared identifier
.Post.cpp(26) : error C2228: left of '.Money' must have class/struct/union
type is ''unknown-type''
.Post.cpp(26) : error C2065: 'PostCost' : undeclared identifier
.Post.cpp(28) : error C2065: 'szPrefix' : undeclared identifier
.Post.cpp(28) : error C3861: 'MessageOutput': identifier not found
.Post.cpp(31) : error C2065: 'BYTE' : undeclared identifier
.Post.cpp(31) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(33) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(33) : error C2065: 'BYTE' : undeclared identifier
.Post.cpp(33) : error C2059: syntax error : ')'
.Post.cpp(34) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(34) : error C3861: 'memset': identifier not found
.Post.cpp(35) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(36) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(37) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(37) : error C2065: 'gObj' : undeclared identifier
.Post.cpp(37) : error C2228: left of '.Nick' must have class/struct/union
type is ''unknown-type''
.Post.cpp(37) : error C2065: 'gObj' : undeclared identifier
.Post.cpp(37) : error C2228: left of '.Nick' must have class/struct/union
type is ''unknown-type''
.Post.cpp(37) : error C3861: 'memcpy': identifier not found
.Post.cpp(37) : error C3861: 'strlen': identifier not found
.Post.cpp(38) : error C2882: 'Text' : illegal use of namespace identifier in expression
.Post.cpp(38) : error C3861: 'sprintf': identifier not found
.Post.cpp(39) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(39) : error C3861: 'memcpy': identifier not found
.Post.cpp(39) : error C3861: 'strlen': identifier not found
.Post.cpp(40) : error C3861: 'strlen': identifier not found
.Post.cpp(41) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(42) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(43) : error C2065: 'gObj' : undeclared identifier
.Post.cpp(43) : error C2228: left of '.Money' must have class/struct/union
type is ''unknown-type''
.Post.cpp(43) : error C2065: 'PostCost' : undeclared identifier
.Post.cpp(44) : error C2065: 'gObj_Money' : undeclared identifier
.Post.cpp(44) : error C3861: 'gObj_Write': identifier not found
.Post.cpp(45) : error C3861: 'MoneySend': identifier not found
.Post.cpp(46) : error C2065: 'Packet' : undeclared identifier
.Post.cpp(46) : error C3861: 'free': identifier not found
Build log was saved at "file://c:Documents and SettingsMihaiDesktopFolder nouPostPostDebugBuildLog.htm"
Post - 56 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我需要做什么?
我该怎么做才能让它发挥作用。
我正在使用:Visual C++ 2008 Express Edition
。
\Post.cpp(6):错误C3861:"gObjIsConnected":找不到标识符
意味着编译器不知道gObjIsConnected
是什么意思。看起来你在那里调用一个函数或函数对象,但由于你没有显示SSCCE,你只能猜测它是在一些没有包含的头中声明的。包括相应的标题,错误应该会消失。
对于DataSend
和许多其他identifier not found
消息也是如此。
\Post.cpp(10):错误C2061:语法错误:标识符"LPCSTR"
这个只是略有不同,因为它不是函数或变量。您在这里使用的LPCSTR
类似于一个类型,但编译器不知道它是一个类型。原因与其他错误类似:您未能包含定义该类型的标头(我担心它是WinAPI标头之一)
其余的原因基本相同。包括丢失的标题,您的大多数错误将消失。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'