ここでは、コードです: ::C4700警告:のmalloc、スコープ、初期化(またはその欠如)
// allocation
void allocateSymbolStorage(char **pepperShakerList, char **pepperList)
{
// allocate storage for an array of pointers
pepperShakerList = (char **) malloc(MAX_PEPPER_SHAKERS * sizeof(char *));
for (int i = 0; i < MAX_PEPPER_SHAKERS; i++)
{
if ((pepperShakerList[i] = (char *) malloc(MAX_SHAKERNAME_LENGTH * sizeof(char))) == NULL)
fatalError("failed pepperShakerList alloc");
}
// allocate storage for an array of pointers
pepperList = (char **) malloc(MAX_PEPPERS * sizeof(char *));
for (int i = 0; i < MAX_PEPPERS; i++)
{
if ((pepperList[i] = (char *) malloc(MAX_PEPPER_LENGTH * sizeof(char))) == NULL)
fatalError("failed pepperList alloc");
}
}
void buildPepperShakers(void)
{
char **pepperShakerList, **pepperList;
allocateSymbolStorage(pepperShakerList, pepperList);
// ....
freeSymbolStorage(pepperShakerList, pepperList);
}
ここではVS 2010のエラーです初期化されていないローカル変数は、 'pepperList'
を使用ここでは混乱があります: char **がallocate関数で割り当てられている場合にエラーが発生するのはなぜですか?範囲外になるのは問題なのでしょうか?
'symbolList'はありません。あなたは 'pepperList'を意味しますか?どのラインがエラーを投げていますか? – Borodin
私の人生では、上記のコードで 'symbolList'を見つけることはできません... –