how does url within function body get compiled(函数体内的 url 是如何编译的)
问题描述
我刚刚将一个 url 粘贴到我的代码中,忘记评论它,但看到 MSVC++ 成功编译它,我很惊讶.我的代码是这样的,
I just pasted a url to my code, and forgot to comment it, but I was surprised to see MSVC++ compiled it successfully. My code is like this,
void my_function()
{
http://www.google.co.in/
}
这怎么会被 MSVC++ 编译?
How come this gets compiled by MSVC++?
推荐答案
其实http后面跟一个冒号被当成标签通过 C++,您可以在 goto 语句(如 goto http;)和其他语句(即 //www.google.co.in) 被视为单行注释.这就是它被编译的原因.
Actually, http followed by a colon is treated as a label by C++, which you can use in goto statements (like goto http;), and the rest (i.e //www.google.co.in) is treated as single line comment. That's why it gets compiled.
查看更多,
void your_function()
{
http://www.google.co.in/
https://www.crazy_c++.com/
ftp://c++_is_fun.edu
//your code here
int i = 10 ; //atleast one line of code is needed here to get compiled!
}
<小时>
顺便说一句,我认为您编写的示例不会被编译.url 后面应该至少有一行代码,然后才能在我的 PC 上编译.我正在使用 MSVC++ 2008.
By the way, I don't think the example you've written would get compiled. There should be at least one line of code after the url, only then it gets compiled on my PC. I'm using MSVC++ 2008.
这篇关于函数体内的 url 是如何编译的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:函数体内的 url 是如何编译的
基础教程推荐
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- CString 到 char* 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
