05-01-2010
Internals of the printf function?
hey all, im a new programmer.
i was wondering how you would go about writing the printf function yourself? it is my understanding that when you call printf you are calling an already written function and just providing an argument? if this is the case, is it possible to write that function yourself with just the bare primitives of the language? i only want to know because i am curious about how things like that work.
---------- Post updated 05-01-10 at 01:19 AM ---------- Previous update was 04-30-10 at 10:05 PM ----------
just to update, i've researched that the gcc compiler is written mostly in C, and so it's likely that the code for all these built-in c functions are written in C as well. so i take that to mean i could somehow write a printf-like function.
i suppose my best bet would be to look at the gcc source and just find it. however, not being a good programmer yet ( i only started just last week), i have no idea where i would find it
. if anyone could point me in the right direction, or explain how i might write it, i would be very happy
10 More Discussions You Might Find Interesting
1. Filesystems, Disks and Memory
will anybody tell me how can i access all the fields of process table .if there is any structure and a system call please specify . (1 Reply)
Discussion started by: vish_shan
1 Replies
2. HP-UX
. (2 Replies)
Discussion started by: Driver
2 Replies
3. Shell Programming and Scripting
Here is the code I'm using
{
printf("%11d %4.2f\% %4.2f\%\n", $1,$2,$3);
}
I want the output to look something like
1235415234 12.24% 52.46%
Instead it looks something like
319203842 42.27\%4.2f\%
How do I just print a "%" without awk or printf thinking I'm trying to do... (1 Reply)
Discussion started by: Awanka
1 Replies
4. Programming
I use FreeBSD,and use signal,like follows:
signal(SIGHUP,sig_hup);
signal(SIGIO,sig_io);
when I run call following code,it can run,but I find a puzzled question,it should print some information,such as printf("execute main()") will print execute main(),but in fact,printf fuction print... (2 Replies)
Discussion started by: konvalo
2 Replies
5. Linux
Hi,
Does anybody have a good pointer on Linux kernel internals for ARM architecture? I can locate plenty for x86 but since ARM is RISC I think there would be subtle changes. So if somebody has a knowledge of good document on Linux Kernel internals for ARM or even a comparative study of kernel on... (0 Replies)
Discussion started by: Rakesh Ranjan
0 Replies
6. Programming
Hello Gurus,
i am ok with the concepts of c language but i would like to know
more about the internals of c with respect to the compilers
what happens when we say
gcc filename.c
the a.out will get created(what actaully compiler does to the code inaddition to generating object code)
... (5 Replies)
Discussion started by: MrUser
5 Replies
7. UNIX for Dummies Questions & Answers
#include<stdio.h>
int counter;
int fibonacci(int n)
{
counter += 1;
if ( n <= 2 )
return 1;
else
return fibonacci(n-1) + fibonacci(n-2);
}
int main(void)
{
int i;
int sum ;
for( i = 1 ; i<= 10; i++)
{
counter = 0;
sum... (1 Reply)
Discussion started by: vincent__tse
1 Replies
8. Programming
Hi friends,
Hope everyone is doing well. Please have a look at this simple program, you will figure out what I want.
#include <stdio.h>
int main()
{
printf("Enter an integer!\n");
scanf( "%d", 134511890 ); // Valid address on my computer
printf( "%d\n", ???? );
return 0;
}
... (3 Replies)
Discussion started by: gabam
3 Replies
9. UNIX for Advanced & Expert Users
When we put a breakpoint using gcc then what all things happen internally and how the gdb using break is able to pause the execution of process( instead of killing it ) and later on resume the process execution? (0 Replies)
Discussion started by: rupeshkp728
0 Replies
10. What is on Your Mind?
Hello,
Long-time Unix hacker here - I've worked on four variants of the kernel prior to the introduction of Linux. In my spare time, I've written Linux (Ubuntu) device drivers, kernel modules, cross-compiled, and built the kernel.
I'd like to do Linux internals/device drivers as a day job,... (1 Reply)
Discussion started by: OriginalVersion
1 Replies
WINEGCC(1) Wine Developers Manual WINEGCC(1)
NAME
winegcc - Wine C and C++ MinGW Compatible Compiler
SYNOPSIS
winegcc [options] infile...
DESCRIPTION
winegcc is a gcc wrapper which tries to provide a MinGW compatible compiler under Linux. This is most useful to Win32 developers who can
simply take their MinGW code from Windows, and recompile it without modifications under Winelib on Linux. wineg++ accepts mostly the same
options as winegcc.
The goal of winegcc is to be able to simply replace gcc/g++/windres with winegcc/wineg++/wrc in a MinGW Makefile, and just recompile the
application using Winelib under Wine. While typically there are small adjustments that must be made to the application source code and/or
Makefile, it is quite easy to do them in a fashion that is compatible between the MinGW and Wine environments.
This manual will document only the differences from gcc; please consult the gcc manual for more information on those options.
OPTIONS
gcc options: All gcc options are supported, and are passed along to the backend compiler.
-Bprefix
This option specifies where to find the executables, libraries, include files, and data files of the compiler itself. This is a
standard gcc option that has been extended to recognize a prefix ending with '/tools/winebuild', in which case winegcc enters a spe-
cial mode for building Wine itself. Developers should avoid prefixes ending with the magic suffix, or if that is not possible, sim-
ply express it differently, such as '/tools/winebuild/', to avoid the special behaviour.
-fno-short-wchar
Override the underlying type for wchar_t to be the default for the target, instead of using short unsigned int, which is the default
for Win32.
-mconsole
This option passes '--subsystem console' to winebuild, to build console applications. It is the default.
-mno-cygwin
Use Wine's implementation of MSVCRT, instead of linking against the host system's libc. This is necessary for the vast majority of
Win32 applications, as they typically depend on various features of MSVCRT. This switch is also used by the MinGW compiler to link
against MSVCRT on Windows, instead of linking against Cygwin's libc. Sharing the syntax with MinGW makes it very easy to write Make-
files that work under Wine, MinGW+MSYS, or MinGW+Cygwin.
-municode
Set the default entry point of the application to be the Unicode wmain() instead of the standard main().
-mwindows
This option adds -lgdi32, -lcomdlg32, and -lshell32 to the list of default libraries, and passes '--subsystem windows' to winebuild
to build graphical applications.
-nodefaultlibs
Do not use the standard system libraries when linking. These include at a minimum -lkernel32, -luser32, -ladvapi32, and any default
libraries used by the backend compiler. The -mwindows option augments the list of default libraries as described above.
-nostartfiles
Do not add the winecrt0 library when linking.
-Wb,option
Pass option as an option to winebuild. If option contains commas, it is split into multiple options at the commas.
DEFINES
winegcc defines __WINE__, for code that needs to know when it is being compiled under Wine. It also defines WIN32, _WIN32, __WIN32,
__WIN32__, __WINNT, and __WINNT__ for compatibility with MinGW.
BUGS
The dllimport/dllexport attributes are not supported at the moment, due to lack of support for these features in the ELF version of gcc.
Static linking is not currently supported against Wine's DLL. As a result, the -static, --static, and -Wl,-static options will generate an
error.
AUTHORS
winegcc was written by Dimitrie O. Paun.
SEE ALSO
gcc(1), winebuild(1), wrc(1), wine(1), Winelib User Guide, Wine Developers Guide.
Wine 1.2-rc6 October 2005 WINEGCC(1)