c - How to print to console (Linux) without the standard library (libc) -


i'm not using standard library, since target x86 linux distro limited.

#include <unistd.h>  void _start () {       const char msg[] = "hello world";       write( stdout_fileno, msg, sizeof( msg ) - 1 ); } 

i want print text console, can't, there other way this. code above wont work because depends on standard library gcc test.cpp -o test -nostdlib

if don't have libc, need craft write() system call scratch write standard output.

see resource details: http://weeb.ddns.net/0/programming/c_without_standard_library_linux.txt

code example above link:

void* syscall5(     void* number,     void* arg1,     void* arg2,     void* arg3,     void* arg4,     void* arg5 );  typedef unsigned long int uintptr; /* size_t */ typedef long int intptr; /* ssize_t */  static intptr write(int fd, void const* data, uintptr nbytes) {     return (intptr)         syscall5(             (void*)1, /* sys_write */             (void*)(intptr)fd,             (void*)data,             (void*)nbytes,             0, /* ignored */             0  /* ignored */         ); }  int main(int argc, char* argv[])  {     write(1, "hello\n", 6);     return 0; } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -