473,732 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

K&R -> C99?

Looking for a program that will convert K&R C source files (including
headers) to C99 (or at least some early ANSI standard) and it must
recognize typedefs and preserve argument promotion; protoize doesn't
and cproto tries but doesn't do a good job

Zach

Aug 4 '07 #1
4 2112
Zach <ne****@gmail.c omwrote:
Looking for a program that will convert K&R C source files (including
headers) to C99 (or at least some early ANSI standard) and it must
recognize typedefs and preserve argument promotion; protoize doesn't
and cproto tries but doesn't do a good job
oh (noting of course that non-hypothetical programs are off-topic),
what sort of problem did you run into with cproto?

http://invisible-island.net/cproto/

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Aug 4 '07 #2
Zach wrote:
Looking for a program that will convert K&R C source files (including
headers) to C99 (or at least some early ANSI standard) and it must
recognize typedefs and preserve argument promotion; protoize doesn't
and cproto tries but doesn't do a good job
Promotion is the hard part, so hard I don't think it
can be done perfectly. For example, I don't think there
is *any* way to write a prototyped function equivalent to

int f(c)
char c;
{ ... }

.... because char promotes to int on most platforms but
to unsigned int on a few. You'd get similar problems with

int g(x)
int16_t x;
{ ... }

.... but I imagine this would be rarer; K&R-style functions
probably predate the invention of C99 types.

Can you explain your situation a little more? For
example, why do you want to introduce prototypes AND
retain the argument promotions of un-prototyped functions?
Planning on converting only part of the code (ick)?

Or attack it from the other side: Explain just what it
is about the tools you've tried that fails to meet your need.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Aug 4 '07 #3
Eric Sosman <es*****@ieee-dot-org.invalidwrit es:
Zach wrote:
>Looking for a program that will convert K&R C source files (including
headers) to C99 (or at least some early ANSI standard) and it must
recognize typedefs and preserve argument promotion; protoize doesn't
and cproto tries but doesn't do a good job

Promotion is the hard part, so hard I don't think it
can be done perfectly. For example, I don't think there
is *any* way to write a prototyped function equivalent to

int f(c)
char c;
{ ... }

... because char promotes to int on most platforms but
to unsigned int on a few.
[...]

But that's still legal C99.

The OP probably wants C99 with prototypes for all functions, but
that's not quite what he said.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 4 '07 #4
In article <11************ **********@x35g 2000prf.googleg roups.com>, Zach
<ne****@gmail.c omwrites
>Looking for a program that will convert K&R C source files (including
headers) to C99 (or at least some early ANSI standard) and it must
recognize typedefs and preserve argument promotion; protoize doesn't
and cproto tries but doesn't do a good job
You don't say if it is K&R 1 or K&R2

K&R 2 is similar to ANSI/ISO C 89/90

Most of compilers use ISO C95 (C90 + A1 + TC1 + TC2)

ISO C99 has not really been implemented very widely

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Aug 5 '07 #5

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

Similar topics

9
8579
by: Collin VanDyck | last post by:
I have a basic understanding of this, so forgive me if I am overly simplistic in my explanation of my problem.. I am trying to get a Java/Xalan transform to pass through a numeric character reference (i.e.  ) and it seems to be converting the character to its UNICODE representation. Take this source XML document: <?xml version="1.0" encoding="UTF-8"?>
1
11443
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a href="mailto:DrTebi@yahoo.com">DrTebi</a> This would work like a regular mailto link in any browser, but wouldn't be visible to spiders if they don't have a function to decode it.
0
2422
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a href="http://blah.com/?test=test&amp;amp;test2=test2">Test2&amp;amp;</a> This results in the following HTML Code:
4
3027
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: /mypage.asp?value1=1&amp;value2=4&amp; ... which of course means nothing to asp.
6
47441
by: Rich Wallace | last post by:
All, I receive an xml doc with an element which contains a &amp; in the data. I am attempting to insert the data into a SQL Server database and I want to convert the &amp; to a "&" character before I perform the insert. Is the a way in VB.NET to perform this? -Rich
8
2815
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
11
6438
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved and
14
5934
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only because of this, so I hope some of you gurus can enlighten me with this :) In what circumstances can the "&amp;" in the source code be involuntary changed to "&" by a browser when or other software, when editing and uploading the file to the web...
12
10112
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b) ..... // xsl contents abc.aspx?p1=v1&amp;p2=<xsl:value-of select="$v2" />
7
4626
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get BeautifulSoup to clean those up? There are various parsing options related to "&" handling, but none of them seem to do quite the right thing. If I write the BeautifulSoup parse tree back out with "prettify", the loose "&" is still in there. So...
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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 we have to send another system
3
2180
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.