程序在发布版本中编译但不调试 [英] Program compiles in release build but not debug

查看:103
本文介绍了程序在发布版本中编译但不调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在VS 2015中构建遗留C ++程序时遇到问题,它在Release版本中没有错误,但是在Debug中没有错误,它在这个版本中包含这个版本





Hi All, I'm having problems building a legacy C++ program in VS 2015, it builds without errors in Release but not in Debug, the line it baulks at it this


gets_s( ch );

gets_s too few arguments for call





为什么发布版本是我的问题



我尝试过:





Why does it build in Release is my question

What I have tried:

Hi All, I'm having problems building a legacy C++ program in VS 2015, it builds without errors in Release but not in Debug, the line it baulks at it this


<pre lang="c++">
gets_s( ch );

gets_s too few arguments for call





为什么它在Release中构建是我的问题



Why does it build in Release is my question

推荐答案

这可能是由 gets_s()函数的模板重载引起的,该函数可能与调试版本的行为不同。 />


我在VS 2017中试过这个并且它在调试模式下编译得很好:

This is probably sourced by the template overload of the gets_s() function which might behave differently with debug builds.

I tried this with VS 2017 and it compiles fine in debug mode:
char ch[10];
gets_s(ch);

因此可能会对你的 ch 变量的声明感兴趣。



为避免错误,您可以明确传递大小:

So it might be of interest how your ch variable is declared.

To avoid the error you can pass the size explicitly:

char ch[10];
gets_s(ch, sizeof(ch));


这篇关于程序在发布版本中编译但不调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆