You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int main()
{
struct dog d;
set_dog(&d, 70);
//printf("hello world %i\r\n", d.b);
printf("hello world %i\r\n" d.b); //I forget a comma
return 0;
}
The text was updated successfully, but these errors were encountered:
zzdmfk
changed the title
When we passing wrong arguments to printf (i.e forget a comma between 2 arguments), compiler can not check it out, and main function can not be parsered.
When we passing wrong arguments to printf (i.e forget a comma between 2 arguments), compiler can not check it out, and main function can not be parsed.
Aug 21, 2023
Compiler outputs:
george@george-ubuntu:~/Desktop/gitcompiler/PeachCompiler$ ./main
section .data
section .text
extern printf
global set_dog
; set_dog function
set_dog:
push ebp
mov ebp, esp
push dword [ebp+12]
lea ebx, [ebp+8]
push ebx
pop ebx
mov ebx, [ebx]
add ebx, 4
push ebx
pop edx
pop eax
mov dword [edx], eax
pop ebp
ret
section .data
section .rodata
everything compiled file
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib32/Scrt1.o: in function _start': (.text+0x22): undefined reference to main'
collect2: error: ld returned 1 exit status
nasm -f elf32 ./test -o ./test.o && gcc -m32 ./test.o -o ./test
And I debugged it, found the function 'main' can not be parsed correctly in 'parse_function'.
zzdmfk
changed the title
When we passing wrong arguments to printf (i.e forget a comma between 2 arguments), compiler can not check it out, and main function can not be parsed.
If we pass wrong arguments to printf (i.e forget a comma between 2 arguments), compiler can not check it out, and main function can not be parsed.
Aug 22, 2023
C code:
int printf(const char* str, ...);
struct dog
{
int a;
int b;
};
void set_dog(struct dog* d, int x)
{
d->b = x;
}
int main()
{
struct dog d;
set_dog(&d, 70);
//printf("hello world %i\r\n", d.b);
printf("hello world %i\r\n" d.b); //I forget a comma
return 0;
}
The text was updated successfully, but these errors were encountered: