Posts

Showing posts with the label gcc

C - print args without stdlibs

C - print args without stdlibs I just wrote a C program that prints its command line argument without using the standard library or a main() function. My motivation is simply curiosity and to understand how to play with inline assembly. I am using Ubuntu 17.10 x86_64 with the 4.13.0-39-generic kernel and GCC 7.2.0. main() Below is my code which I have tried to comment as much as I understood. The functions print , print_1 , my_exit , and _start() are required by the system to run the executable. Actually, without _start() the linker will emit a warning and the program will segfault. print print_1 my_exit _start() _start() Functions print and print_1 are different. The first one prints out a string to the console, measuring the length of the string internally. The second function needs the string length passed as an argument. The my_exit() function just exits the program, returning the required value, which in my case is the string length or the number of command line arguments. ...

Using iconv in cygwin, I got undefined reference to 'libiconv_open'?

Image
Using iconv in cygwin, I got undefined reference to 'libiconv_open'? I just #include <iconv.h> and I've installed libiconv . I've been puzzled for a long time. Does anyone have an advice? #include <iconv.h> libiconv May be you need to show us the code and log output. Please also look at unix.stackexchange.com/questions/445374/… for a specific case. – matzeri Jul 2 at 14:56 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

is it possible to overwrite strdup from with my own?

is it possible to overwrite strdup from <string.h> with my own? I need to do so because I am supposed to stub this function for unit testing. I am using gcc version 5.4.0. for a lot of other functions that exist in glibc like memcpy I simply wrote the implementation in my .c file and then this implementation was the one used instead of the original, but in case of strdup and some other function I get a compilation error like this one: error: expected identifier or ‘(’ before ‘__extension__’ char* strdup (const char *__s) I know this is because I am trying to use a function name that already exist in string.h although it works with some other functions in their as well. I wish to know if it is possible to bypass this somehow. Welcome to stackoverflow.com. Please take some time to read the help pages, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". Also please t...