I have declared a function tolower in assembly language and I am calling it from my C code which includes standard library. I wonder why this works properly without giving any error as now two functions with same name are present.
My C code:
#include <stdio.h>
#include <string.h>
int main() {
char in0[] = "something";
char in1[] = "SomethinG";
char in2[] = "S0mething";
int i = 0;
while (in0[i]) {
in0[i] = tolower(in0[i]);
in1[i] = tolower(in1[i]);
in2[i] = tolower(in2[i]);
i++;
}
return 0;
}
I can't put my assembly code as it comes under an assignment. I have globally declared tolower function.
.section .data
.section .text
.globl _start
.globl tolower
.type tolower, @function
tolower:
I have compiled using gcc cfile.c assfile.s
Are you sure you are calling the assembler version from the C code, and not the standard library version? How is the assembler code defined? Is it a module (.asm) in your C project, in-lined, a static .DLL library, or .DEF/OBJ import? What compiler, assembler, (and IDE, OS?) are you using? There is not enough information currently to yield a concrete answer, however if there is nothing "defining" the assembler function to C, in a way that C can understand, then it will be oblivious to any naming conflicts. This isn't technically an error either; identical function names are like having two identical house addresses (123_Anystreet) in Canada and Europe. Entirely possible and allowable, but C typically doesn't allow it (and assembler does.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.