当前位置: 首页 > ai >正文

第8篇c++Expression: (L“Buffer is too small“ 0

c#调用c++库报错

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Assertion Failed!

Program: ...ration_oqxa2\mysql_operation\bin\x64\Debug\mysql_operation.exe
File: minkernel\crts\ucrt\inc\corecrt_internal_string_templates.h
Line: 81

Expression: (L"Buffer is too small" && 0)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

 导出库时使用不正确

  char* __stdcall ImgRotate(char* charstr, int degree){std::string imgPath = charstr;//const char* chardata = c_Obj.ImgRotate(imgPath, degree).c_str();std::string str_data = c_Obj.ImgRotate(imgPath, degree);char* charArr = new char[str_data.length() + 1];// strcpy(charArr, str_data.c_str());strcpy_s(charArr, sizeof(charArr), str_data.c_str());return charArr;}

strcpy_s(charArr, sizeof(charArr), str_data.c_str());缓冲区移除

直接使用strcpy

char* __stdcall ImgRotate(char* charstr, int degree){std::string imgPath = charstr;//const char* chardata = c_Obj.ImgRotate(imgPath, degree).c_str();std::string str_data = c_Obj.ImgRotate(imgPath, degree);char* charArr = new char[str_data.length() + 1];strcpy(charArr, str_data.c_str());//  strcpy_s(charArr, sizeof(charArr), str_data.c_str());return charArr;}

预处理器里面添加: _CRT_SECURE_NO_WARNINGS,编译则不会报错

http://www.xdnf.cn/news/19404.html

相关文章:

  • 20.30 QLoRA微调终极指南:Hugging Face参数优化实战,24GB显存直降50%性能不减
  • 【JavaScript】async/await 与 Fetch 传参,PUT,PATCH,文件上传,批量删除等前端案例
  • 二、Git基础命令速查表
  • Goframe 框架下HTTP反向代理并支持MCP所需的SSE协议的实现
  • leetcode算法刷题的第二十三天
  • Windows Qt5.15.17源码使用VS2019编译安装
  • Linux自动化构建工具-make/Makefile
  • C#/.NET/.NET Core技术前沿周刊 | 第 52 期(2025年8.25-8.31)
  • 【论文精读】基于YOLOv3算法的高速公路火灾检测
  • Jenkins 自动构建Vue 项目的一个大坑
  • 计算机毕设选题:基于Python+Django的健康饮食管理系统设计【源码+文档+调试】
  • 【LeetCode 155】—最小栈 - 详解与实现
  • Apache Commons ConvertUtils
  • 电科金仓 KFS 场景化实践路径解析:从行业场景落地看技术价值转化
  • Redis面试重点-2
  • std::thread详解
  • JDK14安装步骤及下载(附小白详细教程)
  • 在Unity中,让子物体不随父物体移动或转动的方法!
  • 数据库索引abc,请问查询哪些字段能命中索引
  • APB验证VIP Agent的各个组件之间的通信
  • 【C++ 】string类:深拷贝与浅拷贝解析
  • ​​告别通用模型局限:5步微调实战指南​
  • 数值分析——非线性方程与方程组的数值解法之迭代法
  • [灵动微电子 MM32BIN560CN MM32SPIN0280]读懂电机MCU 模拟输入运放放大
  • NCCL-TEST ib集群测试UCX代替方案
  • unity tilemap grid 的中心轴
  • Linux中卸载和安装Nginx
  • Python爬虫实战:研究Figures与 Axes,构建社交平台具有决策价值的数据采集和分析系统
  • C 语言进程通信之信号API
  • python---封装