トップページ > プログラム > 2014年03月31日 > AKfTTJsa

書き込み順位&時間帯一覧

16 位/212 ID中時間01234567891011121314151617181920212223Total
書き込み数0000000000000001100001003



使用した名前一覧書き込んだスレッド一覧
デフォルトの名無しさん
Visual Studio 2013 SP3

書き込みレス一覧

Visual Studio 2013 SP3
175 :デフォルトの名無しさん[sage]:2014/03/31(月) 15:59:12.63 ID:AKfTTJsa
↓これはエラー
#include <windows.h>
int hoge(int hoge)
{
if (hoge == 0)
goto hoge;
HGLOBAL h = 0;
return hoge * 2 + (h == NULL);
hoge:
return 0;
}
hoge.c(7) : error C2275: 'HANDLE' : illegal use of this type as an expression
C:\Program Files (x86)\Windows Kits\8.1\include\um\winnt.h(571) : see declaration of 'HANDLE'
hoge.c(7) : error C2146: syntax error : missing ';' before identifier 'h'
hoge.c(7) : error C2065: 'h' : undeclared identifier
hoge.c(8) : error C2065: 'h' : undeclared identifier
hoge.c(8) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
↓これは通る。 なんで?
#include <windows.h>
int hoge(int hoge)
{
if (hoge == 0) {
goto hoge;
}
HANDLE h = 0;
return hoge * 2 + (h == NULL);
hoge:
return 0;
}
> cl -c hoge.c
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
Visual Studio 2013 SP3
176 :デフォルトの名無しさん[sage]:2014/03/31(月) 16:04:11.05 ID:AKfTTJsa
#include <windows.h>
int hoge(int hoge)
{
if (hoge == 0)
goto hoge;
{ }
HANDLE h = 0;
return hoge * 2 + (h == NULL);
hoge:
return 0;
}

#include <windows.h>
int hoge(int hoge)
{
if (hoge == 0)
goto hoge;
int h = 0;
return hoge * 2 + (h == 0);
hoge:
return 0;
}
両方ともとおる。コンパイラのバグか?
Visual Studio 2013 SP3
182 :デフォルトの名無しさん[sage]:2014/03/31(月) 21:13:04.68 ID:AKfTTJsa
ラベル名は別の名前空間だから規格に合ってて問題ない。
引数が外部名(関数名)を隠蔽するのも規格に合ってて問題ない。

if (0)
goto hoge;;
i h;
hoge:

とgoto hoge;のあとに空文でも存在すれば通るね。MS CONNECTに投げてみた。


※このページは、『2ちゃんねる』の書き込みを基に自動生成したものです。オリジナルはリンク先の2ちゃんねるの書き込みです。
※このサイトでオリジナルの書き込みについては対応できません。
※何か問題のある場合はメールをしてください。対応します。