错误:expected constructor, destructor, or type conversion before ‘typedef’ 的解决方法

错误现象:

Compiling TradeData.cpp
/home/dev/mobsys/payServer/include/config.h:35: 错误:expected constructor, destructor, or type conversion before ‘typedef’
/home/dev/mobsys/payServer/include/config.h:60: 错误:expected constructor, destructor, or type conversion before ‘;’ token
make[1]: *** [/home/dev/mobsys/payServer/obj/payServer/TradeData.o] 错误 1
make[1]: Leaving directory `/home/dev/mobsys/payServer/src'

 

源文件:

TradeData.cpp

 

/**
 * 交易数据的序列化处理
 * ============================================================================
 * 版权所有 (C) 2008 覃学涵,并保留所有权利。
 * 网站地址: http://www.tnc.com.cn
 * ============================================================================
 * @author:     qinhan <qinxuehan@tnc.com.cn>
 * @version:    v1.0
 * ---------------------------------------------
 * $Author: qinhan $
 * $Date: 2009-05-18 15:59:12 +0800 (星期一) $
 * $Id: TradeData.h  qinhan $
*/

#ifndef _TradeData_h_
#define _TradeData_h_


#include "config.h"

/*交易指令结构体*/
class TradeData {

public: 

 
 CT_STRUCT value;


 
 TradeData(CT_STRUCT * _value)
 {
  memset(&value,0,sizeof(value));
  memcpy(&value,_value,sizeof(value));
 }

 TradeData()
 {
  memset(&value,0,sizeof(value));
 }

 //序列化对象
 std::string serialize();


 //把字符串解释称结构体
 bool TradeData::unserialize(std::string str);
 
};


#endif

 

 

原因:config.h里面的USING_PTYPES 没包含ptypes头文件所致。

正在启动生成... cmd /c chcp 65001>nul && D:/MinGW/bin/g++.exe -fdiagnostics-color=always -g C:\Users\34171\Desktop\code\.vscode\WJ\wj.c -o C:\Users\34171\Desktop\code\.vscode\WJ\wj.exe C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:1:27: error: expected constructor, destructor, or type conversion before '(' token 1 | printf("菜名: %s\n分类: %s\n食材: %s\n制作步骤: %s\n谁喜欢吃: %s\n", | ^ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:5:21: error: 'found' does not name a type 5 | found = 1; | ^~~~~ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:6:17: error: expected declaration before '}' token 6 | } | ^ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:7:17: error: expected unqualified-id before 'break' 7 | break; | ^~~~~ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:8:9: error: expected declaration before '}' token 8 | } | ^ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:9:5: error: expected declaration before '}' token 9 | } | ^ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:10:5: error: expected unqualified-id before 'if' 10 | if (!found) printf("未找到匹配结果。\n"); | ^~ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:11:14: error: expected constructor, destructor, or type conversion before ';' token 11 | getchar(); | ^ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:12:1: error: expected declaration before '}' token 12 | } | ^ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c: In function 'void view_all_recipes()': C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:16:9: error: 'recipe_count' was not declared in this scope 16 | if (recipe_count == 0) { | ^~~~~~~~~~~~ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:17:9: error: 'printf' was not declared in this scope 17 | printf("目前没有菜谱。\n"); | ^~~~~~ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:1:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'? +++ |+#include <cstdio> 1 | printf("菜名: %s\n分类: %s\n食材: %s\n制作步骤: %s\n谁喜欢吃: %s\n", C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:21:20: error: 'recipes' was not declared in this scope 21 | recipes[i].name, recipes[i].category, | ^~~~~~~ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:20:13: error: 'printf' was not declared in this scope 20 | printf("菜名: %s\n分类: %s\n食材: %s\n制作步骤: %s\n谁喜欢吃: %s\n\n", | ^~~~~~ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:20:13: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'? C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:26:5: error: 'getchar' was not declared in this scope 26 | getchar(); | ^~~~~~~ C:\Users\34171\Desktop\code\.vscode\WJ\wj.c:26:5: note: 'getchar' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'? 生成已完成,但出现错误。 * 终端进程启动失败(退出代码: -1)。 * 终端将被任务重用,按任意键关闭。 * 正在执行任务: C/C++: g++.exe 生成活动文件 正在启动生成... cmd /c chcp 65001>nul && D:/MinGW/bin/g++.exe -fdiagnostics-color=always -g C:\Users\34171\Desktop\code\.vscode\WJ\wj.c -o C:\Users\34171\Desktop\code\.vscode\WJ\wj.exe D:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file C:\Users\34171\Desktop\code\.vscode\WJ\wj.exe: Permission denied collect2.exe: error: ld returned 1 exit status 生成已完成,但出现错误。 * 终端进程已终止,退出代码: -1。 * 终端将被任务重用,按任意键关闭。
07-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值