"" に関する原因と対処

このコンパイルエラーの原因と対処に関して説明します。

スポンサード リンク

Microsoft Visual C++にて以下のソースでコンパイルエラーが発生します:

コンパイルエラーメッセージ:
error C2355: 'this': 静的でないメンバー関数の内部または静的でないデータ メンバー初期化子においてのみ参照できます

ソース(バグ有り):

#include <stdio.h>
#include <stdlib.h>

void test_func(void);

int main(this)
{
atexit(test_func);
printf ("exit main func\n");
return 0; } void test_func(void) {
printf("exit test_func function successfully\n");
return; }


原因:


対処:


ソース(修正済み):

#include <stdio.h>
#include <stdlib.h>

void test_func(void);

int main(void)
{
atexit(test_func);
printf ("exit main func\n");
return 0; } void test_func(void) {
printf("exit test_func function successfully\n");
return; }

スポンサード リンク



[コンパイルエラーコード、メッセージに戻る]