473,491 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do you rewrite codes with " ... va_list va_start va_etc"?

hi

How do you rewrite codes with " ... va_list va_start va_etc", so that
simple c compiler don't have to deal with them. I have written a
simple c->verilog compiler but it can't deal with variable length
arguments. How do you rewrite codes with " ... va_list va_start
va_etc"? I guess (I'm not too sure) maybe it's easier to rewrite the c
code if possible? Modifiying my compiler would mean too much work
right now. I have malloc to deal with too (this one is easy for me.)
Thanks.

Mar 6 '07 #1
4 2418
On Mar 6, 9:49 am, maina...@yahoo.com wrote:
hi

How do you rewrite codes with " ... va_list va_start va_etc", so that
simple c compiler don't have to deal with them. I have written a
simple c->verilog compiler but it can't deal with variable length
arguments. How do you rewrite codes with " ... va_list va_start
va_etc"? I guess (I'm not too sure) maybe it's easier to rewrite the c
code if possible? Modifiying my compiler would mean too much work
right now. I have malloc to deal with too (this one is easy for me.)
Thanks.
Mt thinking right now is this, because there is one more argument
before "...",
I could cast that into "char*" or "void*" and use my own version of
va_*. Any suggestion? I not entirely sure if it's possible without
compiler support. thanks.

Mar 6 '07 #2
In article <11**********************@q40g2000cwq.googlegroups .com>,
<ma******@yahoo.comwrote:
>On Mar 6, 9:49 am, maina...@yahoo.com wrote:
>hi

How do you rewrite codes with " ... va_list va_start va_etc", so that
simple c compiler don't have to deal with them. I have written a
simple c->verilog compiler but it can't deal with variable length
arguments. How do you rewrite codes with " ... va_list va_start
va_etc"? I guess (I'm not too sure) maybe it's easier to rewrite the c
code if possible? Modifiying my compiler would mean too much work
right now. I have malloc to deal with too (this one is easy for me.)
Thanks.

Mt thinking right now is this, because there is one more argument
before "...",
I could cast that into "char*" or "void*" and use my own version of
va_*. Any suggestion? I not entirely sure if it's possible without
compiler support. thanks.
If you know how to find the arguments (if you're the implementor,
you'd better know this, and if it's somebody else's "simple" compiler it
shouldn't be too hard to discover it by looking at the generated code),
and if you can write appropriate magic that you can hide behind the
va_foo macros to access them without compiler support, you can implement
varargs without making changes to the compiler.

I suspect you may be asking the wrong question (what are you Really
Trying To Do?), but if you're intending to ask what it looks to me like
you are asking, examining an existing implementation's stdarg.h macros
might provide some useful clues.
dave

--
Dave Vandervies dj******@csclub.uwaterloo.ca
>Void pointers will automatically be converted to the right type when the
assignment is made. --Simon Biber and
Or to the wrong type, as the case may be. Kaz Kylheku in CLC
Mar 6 '07 #3
On Mar 6, 10:14 am, dj3va...@caffeine.csclub.uwaterloo.ca (Dave
Vandervies) wrote:
In article <1173146521.515776.214...@q40g2000cwq.googlegroups .com>,

<maina...@yahoo.comwrote:
On Mar 6, 9:49 am, maina...@yahoo.com wrote:
hi
How do you rewrite codes with " ... va_list va_start va_etc", so that
simple c compiler don't have to deal with them. I have written a
simple c->verilog compiler but it can't deal with variable length
arguments. How do you rewrite codes with " ... va_list va_start
va_etc"? I guess (I'm not too sure) maybe it's easier to rewrite the c
code if possible? Modifiying my compiler would mean too much work
right now. I have malloc to deal with too (this one is easy for me.)
Thanks.
Mt thinking right now is this, because there is one more argument
before "...",
I could cast that into "char*" or "void*" and use my own version of
va_*. Any suggestion? I not entirely sure if it's possible without
compiler support. thanks.

If you know how to find the arguments (if you're the implementor,
I was not the implementer for the frontend, I only wrote the backend.
I didn't want to deal with "..." when I wrote the backend, and still
feel lazy about deal with it if I can get away with rewriting codes.
(there is only one function needs it.)
Rewriting the backend would require me to go through my own spagetti
codes which was horrible
when I wrote that backend. That was like three years ago. my code was
based on suif if you have to know. Anyway linux's inventor had to deal
with this one when he was a student I guess I have to. I had a feeling
I had to deal with this when I wrote that backend, things that are
difficult to untangle between OS and compiler. Since my original
compiler was only meant to compiler simple code for fpga target, I
promptly ignored that case. I would appreciate if people respond with
more info on the issues involved in dealing with it. Like, give me
hints on what's the fastest way to deal with it. Because obviously I
have two ways to deal with it right now. Anyone with experience on
this please respond. I know this is not entirely a language issue...
you'd better know this, and if it's somebody else's "simple" compiler it
The frontend was not a simple project, it's a university reserch
project.
shouldn't be too hard to discover it by looking at the generated code),
I'm the one who was generating the code, and I had no idea how to deal
with it back then.
and if you can write appropriate magic that you can hide behind the
va_foo macros to access them without compiler support, you can implement
varargs without making changes to the compiler.
So you are saying it's possible to modify the va_* codes without
touching the compiler.
(There is no OS to speak of anyway.)

Do you know more on the interplay between OS and compiler on this va_*
issues?
>
I suspect you may be asking the wrong question (what are you Really
Trying To Do?), but if you're intending to ask what it looks to me like
you are asking, examining an existing implementation's stdarg.h macros
might provide some useful clues.
If you know, why don't you just tell the issues involved? thanks.
>
dave

--
Dave Vandervies dj3va...@csclub.uwaterloo.ca>Void pointers will automatically be converted to the right type when the
assignment is made. --Simon Biber and

Or to the wrong type, as the case may be. Kaz Kylheku in CLC

Mar 6 '07 #4
On Mar 6, 10:14 am, dj3va...@caffeine.csclub.uwaterloo.ca (Dave
Vandervies) wrote:
In article <1173146521.515776.214...@q40g2000cwq.googlegroups .com>,

<maina...@yahoo.comwrote:
On Mar 6, 9:49 am, maina...@yahoo.com wrote:
hi
How do you rewrite codes with " ... va_list va_start va_etc", so that
simple c compiler don't have to deal with them. I have written a
simple c->verilog compiler but it can't deal with variable length
arguments. How do you rewrite codes with " ... va_list va_start
va_etc"? I guess (I'm not too sure) maybe it's easier to rewrite the c
code if possible? Modifiying my compiler would mean too much work
right now. I have malloc to deal with too (this one is easy for me.)
Thanks.
Mt thinking right now is this, because there is one more argument
before "...",
I could cast that into "char*" or "void*" and use my own version of
va_*. Any suggestion? I not entirely sure if it's possible without
compiler support. thanks.

If you know how to find the arguments (if you're the implementor,
you'd better know this, and if it's somebody else's "simple" compiler it
shouldn't be too hard to discover it by looking at the generated code),
and if you can write appropriate magic that you can hide behind the
va_foo macros to access them without compiler support, you can implement
varargs without making changes to the compiler.

I suspect you may be asking the wrong question (what are you Really
Trying To Do?), but if you're intending to ask what it looks to me like
you are asking, examining an existing implementation's stdarg.h macros
might provide some useful clues.
I just realized this can be done without touching compiler or other
kludge :)
Since in my case, the argument list is always 1..3 arguments, no
degenerate cases. no kludge required, thanks wanyway.
>
dave

--
Dave Vandervies dj3va...@csclub.uwaterloo.ca>Void pointers will automatically be converted to the right type when the
assignment is made. --Simon Biber and

Or to the wrong type, as the case may be. Kaz Kylheku in CLC

Mar 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1895
by: Eric Lilja | last post by:
As the title, says: Why doesn't the following program print Hi Charles<newline> when run? #include <stdarg.h> #include <stdio.h> static void va_arg_example(const char *format, ...) { va_list...
188
17185
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
42
3082
by: Martin Jørgensen | last post by:
Hi, I'm trying to move a matlab program into c language. For those who knows matlab, this is the line I want to program in c: hx(1:nx,1:ny) = 0; % nx=10, ny=10 It works on a 2-dimensional...
4
2582
by: neo | last post by:
I want to make one function for pass "n Parameter" with respective functionality, "..." use for parameter but I am not understand how use "..." in function and what is the technical name of this...
10
1298
by: not_a_commie | last post by:
I've seen studies before showing that it is better to rewrite code when more than 25% (or whatever) of the code needs to be changed. I can't seem to locate any references for that at the moment. Do...
5
2486
by: aRTx | last post by:
Can anyone explain how to combine "url rewrite" and header() function. example: header('Location: http://www.abc.com/a.php?username=abc&password=bsd'); rewrite url as:...
29
11048
by: candy_init | last post by:
Hi all, I just came across the following program: #include <stdio.h> int main() { float a = 12.5; printf("%d\n", a); printf("%d\n", *(int *)&a); return 0;
1
5499
by: Chuck Chopp | last post by:
I have some code that is being built on the following: Windows Server 2003, both 32-bit & 64-bit editions Windows Vista, both 32-bit & 64-bit editions Windows Server 2008, both 32-bit & 64-bit...
1
4602
by: mars | last post by:
Which file is the "printf" implemention in glibc? The stdio.c is very small. It seems using __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) And __printf_chk using __nldbl___vfprintf_chk, but...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.