Compiler Issues

Compiler Issues

vs2019

You can not use scanf

VS will use 'scanf':. This function or variable May BE unsafe the Consider a using scanf_s
INS such a mistake, it is a warning of a new version of vc library adds that there is a security risk because Microsoft use scanf, since the C / C ++ strings treatment are based on \ 0 character cut-off, if not search \ 0, prone string vc all cross-border expansion of so-called safety standard library, have added a parameter to specify the length of the string parameter to avoid this kinds of security risks.

Solution: Open the "ConsoleApplication1 Properties" under the "Project" page

1.png

Click Configuration Properties -> c / c ++ -> Preprocessor

2.png

In the preprocessor definitions there to add a line to == _ CRT_SECURE_NO_DEPRECATE ==

3.png

vs2010

Configuration

  1. QQ picture 20191221171039.jpg
  2. Snipaste_2019-12-21_17-09-22.png Snipaste_2019-12-21_17-09-43.png Snipaste_2019-12-21_17-09-59.png

No memory window debug state

QQ picture 20191221171650.jpg

dev-cpp

Run flash back

The sample code

#include<stdio.h>
int main ()
{
    printf("hello world");
}

change

#include<stdio.h>
int main ()
{
    printf("hello world");
    getchar();//getche();也可
}

c99 standard setting (-std)

Turn to [ Tools ] - [ compiler options ] - [ code generation / optimization ] - [ Code Generator ]. In [ language standard selection "] in ISO C99 ", thereafter at compile time you can use the C99 or the C ++ 11 standard.

4.png

All warning (-wall)

There is a joke: a vertical cliff end of the road block sign that says "Warning", the result of programmers all fall down.

Warn­ing 与 Er­ror 不同,程序遇到 Er­ror 就不能正常运行了(甚至都不能通过编译),而 Warn­ing 是说明你的程序有不严谨的地方。新手程序员们应该认真对待 Warn­ing,从而提升代码质量。

在 Dev C++ 中开启显示所有警告的方法如下:【工具】-【编译选项】-【代码生成 / 优化】-【代码生成】,在【代码警告】中将 “显示最多警告信息 (-Wall)” 设置为 Yes 即可。

上述设置其实是在编译时加入了 -Wall 参数。Wall 不是墙的意思,而是 Warn­ing all,即显示所有警告。开启了 Wall 之后,在某种意义上你应该像对待 Er­ror 那样对待 Warn­ing。

5.png

产生调试信息(-g3)

有些版本的 Dev C++ 在刚刚安装完成后默认情况下是不能进行调试的,一旦点击调试按钮,会提示 “没有调试信息”,随后程序崩溃或闪退。

这是因为在编译源代码的时候没有加入调试信息。解决方法如下:【工具】-【编译选项】-【代码生成 / 优化】-【代码生成】,在【连接器】中将 “产生调试信息” 设置为 Yes。

只有产生了调试信息才能对程序进行断点调试。(f5)

6.png
Released two original articles · won praise 8 · views 501

Guess you like

Origin blog.csdn.net/mer_cer/article/details/104240396