解决“invalid conversion from void* to char*”和“deprecated conversion from string constant to 'char*' "

本文介绍了一个简单的C语言程序,该程序用于创建字符串的副本。文章详细解释了为何此程序在C++编译器下会遇到类型转换错误,并提供了修改建议,确保程序能在C++环境下正确运行。

先看下面这个C语言程序,它的作用是使用动态存储分配来创建字符串的副本,如果内存分配失败,duplicate函数就返回空指针。

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

char* duplicate(const char* s)
{
    char* temp = malloc(strlen(s) + 1);

    if (temp == NULL)
        return NULL;

    strcpy(temp, s);
    return temp;
}

int main(void)
{
    char* str = "testing.";
    char* str2 = duplicate(str);

    printf("Original String: %s\n", str);
    printf("Duplicated String: %s\n", str2);
}

使用gcc编译直接通过并打印出下面的结果

Original String: testing.
Duplicated String: testing.

但当使用g++编译时,会出现一个错误和警告,如下

error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

出现error的原因是C++设计得比C更加安全,它不能自动地将void *转换为其它指针类型。而出现warning的原因则是程序试图将字符串字面值(在C++中字符串字面值为const char []类型,而在C语言中则为char []类型)转换为char *类型,因此如果想要使用g++成功编译这个程序并得到预期的结果,可以将源程序修改为

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

char* duplicate(const char* s)
{
    char* temp = (char*) malloc(strlen(s) + 1);

    if (temp == NULL)
        return NULL;

    strcpy(temp, s);
    return temp;
}

int main(void)
{
    char* str = (char*) "testing.";
    char* str2 = duplicate(str);

    printf("Original String: %s\n", str);
    printf("Duplicated String: %s\n", str2);
}
tianhangsong@ubuntu:~/NachOS-4.1/code/build.linux$ make depend g++ -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -M ../lib/bitmap.cc ../lib/debug.cc ../lib/hash.cc ../lib/libtest.cc ../lib/list.cc ../lib/sysdep.cc ../machine/interrupt.cc ../machine/stats.cc ../machine/timer.cc ../machine/console.cc ../machine/machine.cc ../machine/mipssim.cc ../machine/translate.cc ../machine/network.cc ../machine/disk.cc ../threads/alarm.cc ../threads/kernel.cc ../threads/main.cc ../threads/scheduler.cc ../threads/synch.cc ../threads/synchlist.cc ../threads/thread.cc ../userprog/addrspace.cc ../userprog/exception.cc ../userprog/synchconsole.cc ../filesys/directory.cc ../filesys/filehdr.cc ../filesys/filesys.cc ../filesys/pbitmap.cc ../filesys/openfile.cc ../filesys/synchdisk.cc ../network/post.cc > makedep ed - Makefile.dep < eddep rm eddep makedep tianhangsong@ubuntu:~/NachOS-4.1/code/build.linux$ make g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../lib/bitmap.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../lib/debug.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../lib/libtest.cc ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] "7", "8", "9", "10", "11", "12", "13", "14"}; ^ ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../lib/libtest.cc:59:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../lib/sysdep.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/interrupt.cc ../machine/interrupt.cc:29:45: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] static char *intLevelNames[] = { "off", "on"}; ^ ../machine/interrupt.cc:29:45: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] "network recv"}; ^ ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/interrupt.cc:32:18: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/stats.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/timer.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/console.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/machine.cc ../machine/machine.cc:19:27: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] "illegal instruction" }; ^ ../machine/machine.cc:19:27: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/machine.cc:19:27: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/mipssim.cc In file included from ../machine/mipssim.cc:22:0: ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] }; ^ ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.h:227:7: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ../machine/mipssim.cc: In member function ‘void Machine::OneInstruction(Instruction*)’: ../machine/mipssim.cc:139:56: warning: array subscript has type ‘char’ [-Wchar-subscripts] struct OpString *str = &opStrings[instr->opCode]; ^ ../machine/mipssim.cc:158:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] sum = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:158:50: warning: array subscript has type ‘char’ [-Wchar-subscripts] sum = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:159:28: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (!((registers[instr->rs] ^ registers[instr->rt]) & SIGN_BIT) && ^ ../machine/mipssim.cc:159:51: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (!((registers[instr->rs] ^ registers[instr->rt]) & SIGN_BIT) && ^ ../machine/mipssim.cc:160:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] ((registers[instr->rs] ^ sum) & SIGN_BIT)) { ^ ../machine/mipssim.cc:164:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = sum; ^ ../machine/mipssim.cc:168:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] sum = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:169:28: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (!((registers[instr->rs] ^ instr->extra) & SIGN_BIT) && ^ ../machine/mipssim.cc:174:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = sum; ^ ../machine/mipssim.cc:178:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:178:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:182:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:182:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:182:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] + registers[instr->rt]; ^ ../machine/mipssim.cc:186:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] & registers[instr->rt]; ^ ../machine/mipssim.cc:186:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] & registers[instr->rt]; ^ ../machine/mipssim.cc:186:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] & registers[instr->rt]; ^ ../machine/mipssim.cc:190:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] & (instr->extra & 0xffff); ^ ../machine/mipssim.cc:190:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] & (instr->extra & 0xffff); ^ ../machine/mipssim.cc:194:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] == registers[instr->rt]) ^ ../machine/mipssim.cc:194:49: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] == registers[instr->rt]) ^ ../machine/mipssim.cc:201:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (!(registers[instr->rs] & SIGN_BIT)) ^ ../machine/mipssim.cc:206:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] > 0) ^ ../machine/mipssim.cc:211:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] <= 0) ^ ../machine/mipssim.cc:218:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] & SIGN_BIT) ^ ../machine/mipssim.cc:223:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] != registers[instr->rt]) ^ ../machine/mipssim.cc:223:49: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] != registers[instr->rt]) ^ ../machine/mipssim.cc:228:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rt] == 0) { ^ ../machine/mipssim.cc:232:45: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[LoReg] = registers[instr->rs] / registers[instr->rt]; ^ ../machine/mipssim.cc:232:68: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[LoReg] = registers[instr->rs] / registers[instr->rt]; ^ ../machine/mipssim.cc:233:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[HiReg] = registers[instr->rs] % registers[instr->rt]; ^ ../machine/mipssim.cc:233:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[HiReg] = registers[instr->rs] % registers[instr->rt]; ^ ../machine/mipssim.cc:238:43: warning: array subscript has type ‘char’ [-Wchar-subscripts] rs = (unsigned int) registers[instr->rs]; ^ ../machine/mipssim.cc:239:43: warning: array subscript has type ‘char’ [-Wchar-subscripts] rt = (unsigned int) registers[instr->rt]; ^ ../machine/mipssim.cc:258:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[NextPCReg] + 4; ^ ../machine/mipssim.cc:260:31: warning: array subscript has type ‘char’ [-Wchar-subscripts] pcAfter = registers[instr->rs]; ^ ../machine/mipssim.cc:265:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:279:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:297:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = instr->extra << 16; ^ ../machine/mipssim.cc:301:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:313:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:341:41: warning: array subscript has type ‘char’ [-Wchar-subscripts] nextLoadValue = registers[instr->rt]; ^ ../machine/mipssim.cc:365:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:393:41: warning: array subscript has type ‘char’ [-Wchar-subscripts] nextLoadValue = registers[instr->rt]; ^ ../machine/mipssim.cc:421:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[HiReg]; ^ ../machine/mipssim.cc:425:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[LoReg]; ^ ../machine/mipssim.cc:429:40: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[HiReg] = registers[instr->rs]; ^ ../machine/mipssim.cc:433:40: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[LoReg] = registers[instr->rs]; ^ ../machine/mipssim.cc:437:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] Mult(registers[instr->rs], registers[instr->rt], TRUE, ^ ../machine/mipssim.cc:437:48: warning: array subscript has type ‘char’ [-Wchar-subscripts] Mult(registers[instr->rs], registers[instr->rt], TRUE, ^ ../machine/mipssim.cc:442:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] Mult(registers[instr->rs], registers[instr->rt], FALSE, ^ ../machine/mipssim.cc:442:48: warning: array subscript has type ‘char’ [-Wchar-subscripts] Mult(registers[instr->rs], registers[instr->rt], FALSE, ^ ../machine/mipssim.cc:447:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = ~(registers[instr->rs] | registers[instr->rt]); ^ ../machine/mipssim.cc:447:46: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = ~(registers[instr->rs] | registers[instr->rt]); ^ ../machine/mipssim.cc:447:69: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = ~(registers[instr->rs] | registers[instr->rt]); ^ ../machine/mipssim.cc:451:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] | registers[instr->rt]; ^ ../machine/mipssim.cc:451:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] | registers[instr->rt]; ^ ../machine/mipssim.cc:451:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] | registers[instr->rt]; ^ ../machine/mipssim.cc:455:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] | (instr->extra & 0xffff); ^ ../machine/mipssim.cc:455:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] | (instr->extra & 0xffff); ^ ../machine/mipssim.cc:460:23: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 1, registers[instr->rt])) ^ ../machine/mipssim.cc:460:64: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 1, registers[instr->rt])) ^ ../machine/mipssim.cc:466:23: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 2, registers[instr->rt])) ^ ../machine/mipssim.cc:466:64: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 2, registers[instr->rt])) ^ ../machine/mipssim.cc:471:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] << instr->extra; ^ ../machine/mipssim.cc:471:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] << instr->extra; ^ ../machine/mipssim.cc:475:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] << ^ ../machine/mipssim.cc:475:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] << ^ ../machine/mipssim.cc:476:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] & 0x1f); ^ ../machine/mipssim.cc:480:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] < registers[instr->rt]) ^ ../machine/mipssim.cc:480:48: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] < registers[instr->rt]) ^ ../machine/mipssim.cc:481:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = 1; ^ ../machine/mipssim.cc:483:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = 0; ^ ../machine/mipssim.cc:487:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (registers[instr->rs] < instr->extra) ^ ../machine/mipssim.cc:488:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = 1; ^ ../machine/mipssim.cc:490:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = 0; ^ ../machine/mipssim.cc:494:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] rs = registers[instr->rs]; ^ ../machine/mipssim.cc:497:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = 1; ^ ../machine/mipssim.cc:499:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = 0; ^ ../machine/mipssim.cc:503:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] rs = registers[instr->rs]; ^ ../machine/mipssim.cc:504:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] rt = registers[instr->rt]; ^ ../machine/mipssim.cc:506:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = 1; ^ ../machine/mipssim.cc:508:25: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = 0; ^ ../machine/mipssim.cc:512:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] >> instr->extra; ^ ../machine/mipssim.cc:512:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] >> instr->extra; ^ ../machine/mipssim.cc:516:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] >> ^ ../machine/mipssim.cc:516:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rt] >> ^ ../machine/mipssim.cc:517:26: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] & 0x1f); ^ ../machine/mipssim.cc:521:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rt]; ^ ../machine/mipssim.cc:523:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = tmp; ^ ../machine/mipssim.cc:527:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rt]; ^ ../machine/mipssim.cc:528:30: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp >>= (registers[instr->rs] & 0x1f); ^ ../machine/mipssim.cc:529:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = tmp; ^ ../machine/mipssim.cc:533:28: warning: array subscript has type ‘char’ [-Wchar-subscripts] diff = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:533:51: warning: array subscript has type ‘char’ [-Wchar-subscripts] diff = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:534:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (((registers[instr->rs] ^ registers[instr->rt]) & SIGN_BIT) && ^ ../machine/mipssim.cc:534:50: warning: array subscript has type ‘char’ [-Wchar-subscripts] if (((registers[instr->rs] ^ registers[instr->rt]) & SIGN_BIT) && ^ ../machine/mipssim.cc:535:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] ((registers[instr->rs] ^ diff) & SIGN_BIT)) { ^ ../machine/mipssim.cc:539:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = diff; ^ ../machine/mipssim.cc:543:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:543:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:543:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] - registers[instr->rt]; ^ ../machine/mipssim.cc:548:23: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 4, registers[instr->rt])) ^ ../machine/mipssim.cc:548:64: warning: array subscript has type ‘char’ [-Wchar-subscripts] (registers[instr->rs] + instr->extra), 4, registers[instr->rt])) ^ ../machine/mipssim.cc:553:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:585:33: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = registers[instr->rt]; ^ ../machine/mipssim.cc:588:58: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xff000000) | ((registers[instr->rt] >> 8) & ^ ../machine/mipssim.cc:592:58: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xffff0000) | ((registers[instr->rt] >> 16) & ^ ../machine/mipssim.cc:596:58: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xffffff00) | ((registers[instr->rt] >> 24) & ^ ../machine/mipssim.cc:612:27: warning: array subscript has type ‘char’ [-Wchar-subscripts] tmp = registers[instr->rs] + instr->extra; ^ ../machine/mipssim.cc:644:55: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xffffff) | (registers[instr->rt] << 24); ^ ../machine/mipssim.cc:647:53: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xffff) | (registers[instr->rt] << 16); ^ ../machine/mipssim.cc:650:51: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = (value & 0xff) | (registers[instr->rt] << 8); ^ ../machine/mipssim.cc:653:33: warning: array subscript has type ‘char’ [-Wchar-subscripts] value = registers[instr->rt]; ^ ../machine/mipssim.cc:675:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] ^ registers[instr->rt]; ^ ../machine/mipssim.cc:675:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] ^ registers[instr->rt]; ^ ../machine/mipssim.cc:675:67: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rd] = registers[instr->rs] ^ registers[instr->rt]; ^ ../machine/mipssim.cc:679:21: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] ^ (instr->extra & 0xffff); ^ ../machine/mipssim.cc:679:44: warning: array subscript has type ‘char’ [-Wchar-subscripts] registers[instr->rt] = registers[instr->rs] ^ (instr->extra & 0xffff); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/translate.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/network.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../machine/disk.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/alarm.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/kernel.cc ../threads/kernel.cc: In member function ‘void Kernel::Initialize()’: ../threads/kernel.cc:93:38: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] currentThread = new Thread("main"); ^ ../threads/kernel.cc: In member function ‘void Kernel::ThreadSelfTest()’: ../threads/kernel.cc:152:39: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] semaphore = new Semaphore("test", 0); ^ ../threads/kernel.cc: In member function ‘void Kernel::NetworkTest()’: ../threads/kernel.cc:208:22: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] char *data = "Hello there!"; ^ ../threads/kernel.cc:209:21: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] char *ack = "Got it!"; ^ In file included from ../threads/synchlist.h:49:0, from ../threads/kernel.cc:14: ../threads/synchlist.cc: In instantiation of ‘SynchList<T>::SynchList() [with T = int]’: ../threads/kernel.cc:158:20: required from here ../threads/synchlist.cc:26:10: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] lock = new Lock("list lock"); ^ ../threads/synchlist.cc:27:15: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] listEmpty = new Condition("list empty cond"); ^ ../threads/synchlist.cc: In instantiation of ‘void SynchList<T>::SelfTest(T) [with T = int]’: ../threads/kernel.cc:159:25: required from here ../threads/synchlist.cc:120:39: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] Thread *helper = new Thread("ping"); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/main.cc ../threads/main.cc:59:8: warning: extra tokens at end of #endif directive [enabled by default] #endif TUT ^ In file included from ../threads/main.cc:41:0: ../lib/copyright.h:23:26: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] static char *copyright = "Copyright (c) 1992-1993 The Regents of the University of California. All rights reserved."; ^ ../threads/main.cc: In function ‘int main(int, char**)’: ../threads/main.cc:182:22: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] char *debugArg = ""; ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/scheduler.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/synch.cc ../threads/synch.cc: In member function ‘void Semaphore::SelfTest()’: ../threads/synch.cc:138:39: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] Thread *helper = new Thread("ping"); ^ ../threads/synch.cc:141:35: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] ping = new Semaphore("ping", 0); ^ ../threads/synch.cc: In constructor ‘Lock::Lock(char*)’: ../threads/synch.cc:161:40: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] semaphore = new Semaphore("lock", 1); // initially, unlocked ^ ../threads/synch.cc: In member function ‘void Condition::Wait(Lock*)’: ../threads/synch.cc:250:43: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] waiter = new Semaphore("condition", 0); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../threads/thread.cc ../threads/thread.cc: In member function ‘void Thread::SelfTest()’: ../threads/thread.cc:430:43: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] Thread *t = new Thread("forked thread"); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../userprog/addrspace.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../userprog/exception.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../userprog/synchconsole.cc ../userprog/synchconsole.cc: In constructor ‘SynchConsoleInput::SynchConsoleInput(char*)’: ../userprog/synchconsole.cc:23:33: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] lock = new Lock("console in"); ^ ../userprog/synchconsole.cc:24:44: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] waitFor = new Semaphore("console in", 0); ^ ../userprog/synchconsole.cc: In constructor ‘SynchConsoleOutput::SynchConsoleOutput(char*)’: ../userprog/synchconsole.cc:79:34: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] lock = new Lock("console out"); ^ ../userprog/synchconsole.cc:80:45: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] waitFor = new Semaphore("console out", 0); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/directory.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/filehdr.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/filesys.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/pbitmap.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/openfile.cc g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../filesys/synchdisk.cc ../filesys/synchdisk.cc: In constructor ‘SynchDisk::SynchDisk()’: ../filesys/synchdisk.cc:30:46: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] semaphore = new Semaphore("synch disk", 0); ^ ../filesys/synchdisk.cc:31:38: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] lock = new Lock("synch disk lock"); ^ g++ -ftemplate-depth-100 -Wno-deprecated -g -Wall -fpermissive -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -DFILESYS_STUB -DRDATA -DSIM_FIX -DTUT -Dx86 -DLINUX -DCHANGED -m32 -c ../network/post.cc ../network/post.cc: In constructor ‘PostOfficeInput::PostOfficeInput(int)’: ../network/post.cc:155:60: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] messageAvailable = new Semaphore("message available", 0); ^ ../network/post.cc:162:43: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] Thread *t = new Thread("postal worker"); ^ ../network/post.cc: In constructor ‘PostOfficeOutput::PostOfficeOutput(double)’: ../network/post.cc:268:50: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] messageSent = new Semaphore("message sent", 0); ^ ../network/post.cc:269:44: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] sendLock = new Lock("message send lock"); ^ In file included from ../threads/synchlist.h:49:0, from ../network/post.h:34, from ../network/post.cc:20: ../threads/synchlist.cc: In instantiation of ‘SynchList<T>::SynchList() [with T = Mail*]’: ../network/post.cc:52:38: required from here ../threads/synchlist.cc:26:10: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] lock = new Lock("list lock"); ^ ../threads/synchlist.cc:27:15: warning: deprecated conversion from string constant tochar*’ [-Wwrite-strings] listEmpty = new Condition("list empty cond"); ^ /lib/cpp -P -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -Dx86 -DLINUX ../threads/switch.s > swtch.s as -o switch.o swtch.s swtch.s: Assembler messages: swtch.s:7: 错误: invalid instruction suffix for `push' swtch.s:9: 错误: invalid instruction suffix for `push' swtch.s:10: 错误: operand type mismatch for `call' swtch.s:11: 错误: operand type mismatch for `call' swtch.s:12: 错误: operand type mismatch for `call' swtch.s:14: 错误: invalid instruction suffix for `pop' Makefile:342: recipe for target 'switch.o' failed make: *** [switch.o] Error 1
05-12
C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:194:36: error: invalid conversion from 'void*' to 'jpeg_dec_io_t*' [-fpermissive] 194 | jpeg_dec_io_t *jpeg_io = calloc(1, sizeof(jpeg_dec_io_t)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ | | | void* C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:200:46: error: invalid conversion from 'void*' to 'jpeg_dec_header_info_t*' [-fpermissive] 200 | jpeg_dec_header_info_t *out_info = calloc(1, sizeof(jpeg_dec_header_info_t)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | void* C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:210:33: error: invalid conversion from 'jpeg_dec_handle_t' {aka 'void*'} to 'void**' [-fpermissive] 210 | ret = jpeg_dec_parse_header(jpeg_dec, jpeg_io, out_info); | ^~~~~~~~ | | | jpeg_dec_handle_t {aka void*} In file included from C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:35: C:/Users/shang/Desktop/hello_opencv/components/esp_jpeg/include/esp_jpeg_dec.h:145:55: note: initializing argument 1 of 'jpeg_error_t jpeg_dec_parse_header(void**, jpeg_dec_io_t*, jpeg_dec_header_info_t*)' 145 | jpeg_error_t jpeg_dec_parse_header(jpeg_dec_handle_t *jpeg_dec, jpeg_dec_io_t *io, jpeg_dec_header_info_t *out_info);//解析 JPEG 图像的头部信息,而不进行完整的解码。 | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:222:28: error: invalid conversion from 'jpeg_dec_handle_t' {aka 'void*'} to 'void**' [-fpermissive] 222 | ret = jpeg_dec_process(jpeg_dec, jpeg_io); | ^~~~~~~~ | | | jpeg_dec_handle_t {aka void*} C:/Users/shang/Desktop/hello_opencv/components/esp_jpeg/include/esp_jpeg_dec.h:161:50: note: initializing argument 1 of 'jpeg_error_t jpeg_dec_process(void**, jpeg_dec_io_t*)' 161 | jpeg_error_t jpeg_dec_process(jpeg_dec_handle_t *jpeg_dec, jpeg_dec_io_t *io); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:227:1: error: jump to label '_exit' 227 | _exit: | ^~~~~ C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:212:14: note: from here 212 | goto _exit; | ^~~~~ C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:217:9: note: crosses initialization of 'int inbuf_consumed' 217 | int inbuf_consumed = jpeg_io->inbuf_len - jpeg_io->inbuf_remain; | ^~~~~~~~~~~~~~ C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:229:20: error: invalid conversion from 'jpeg_dec_handle_t' {aka 'void*'} to 'void**' [-fpermissive] 229 | jpeg_dec_close(jpeg_dec); | ^~~~~~~~ | | | jpeg_dec_handle_t {aka void*} C:/Users/shang/Desktop/hello_opencv/components/esp_jpeg/include/esp_jpeg_dec.h:172:48: note: initializing argument 1 of 'jpeg_error_t jpeg_dec_close(void**)' 172 | jpeg_error_t jpeg_dec_close(jpeg_dec_handle_t *jpeg_dec);//关闭jpeg解码器 | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp: In function 'void app_main()': C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:281:40: error: invalid conversion from 'void*' to 'jpeg_dec_io_t*' [-fpermissive] 281 | jpeg_dec_io_t *jpeg_io = calloc(1, sizeof(jpeg_dec_io_t)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ | | | void* C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:282:50: error: invalid conversion from 'void*' to 'jpeg_dec_header_info_t*' [-fpermissive] 282 | jpeg_dec_header_info_t *out_info = calloc(1, sizeof(jpeg_dec_header_info_t)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | void* C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:292:37: error: invalid conversion from 'jpeg_dec_handle_t' {aka 'void*'} to 'void**' [-fpermissive] 292 | ret = jpeg_dec_parse_header(jpeg_dec, jpeg_io, out_info); | ^~~~~~~~ | | | jpeg_dec_handle_t {aka void*} C:/Users/shang/Desktop/hello_opencv/components/esp_jpeg/include/esp_jpeg_dec.h:145:55: note: initializing argument 1 of 'jpeg_error_t jpeg_dec_parse_header(void**, jpeg_dec_io_t*, jpeg_dec_header_info_t*)' 145 | jpeg_error_t jpeg_dec_parse_header(jpeg_dec_handle_t *jpeg_dec, jpeg_dec_io_t *io, jpeg_dec_header_info_t *out_info);//解析 JPEG 图像的头部信息,而不进行完整的解码。 | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ C:/Users/shang/Desktop/hello_opencv/main/hello_opencv.cpp:322:24: error: invalid conversion from 'jpeg_dec_handle_t' {aka 'void*'} to 'void**' [-fpermissive] 322 | jpeg_dec_close(jpeg_dec); | ^~~~~~~~ | | | jpeg_dec_handle_t {aka void*} C:/Users/shang/Desktop/hello_opencv/components/esp_jpeg/include/esp_jpeg_dec.h:172:48: note: initializing argument 1 of 'jpeg_error_t jpeg_dec_close(void**)' 172 | jpeg_error_t jpeg_dec_close(jpeg_dec_handle_t *jpeg_dec);//关闭jpeg解码器 | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ C:/Users/shang/Desktop/hello_opencv/main/opencv/opencv2/core/mat.inl.hpp: In instantiation of 'cv::Mat::Mat(const cv::Matx<_Tp, m, n>&, bool) [with _Tp = double; int m = 2; int n = 3]': C:/Users/shang/Desktop/hello_opencv/main/opencv/opencv2/imgproc.hpp:2442:64: required from here C:/Users/shang/Desktop/hello_opencv/main/opencv/opencv2/core/mat.inl.hpp:688:23: warning: arithmetic between different enumeration types 'cv::Mat::<unnamed enum>' and 'cv::traits::Type<double>::<unnamed enum>' is deprecated [-Wdeprecated-enum-enum-conversion] 688 | : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0), | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ ninja: build stopped: subcommand failed.这个是什么错误
06-05
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值