473,811 Members | 3,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

An Empirical Analysis of CPP Use

pag.csail.mit.e du/~mernst/ pubs/c-preprocessor-tse2002.pdf

Abstract:
This is the first empirical study of the use of the C
macro preprocessor, Cpp. To determine how the preprocessor is
used in practice, this paper analyzes 26 packages comprising 1.4
million lines of publicly available C code. We determine the
incidence of C preprocessor usage?whether in macro definitions,
macro uses, or dependences upon macros?that is complex,
potentially problematic, or inexpressible in terms of other C or
C++ language features. We taxonomize these various aspects of
preprocessor use and particularly note data that are material to
the development of tools for C or C++, including translating from
C to C++ to reduce preprocessor usage. Our results show that,
while most Cpp usage follows fairly simple patterns, an effective
program analysis tool must address the preprocessor. The intimate
connection between the C programming language and Cpp, and Cpp?s
unstructured transformations of token streams often hinder both
programmer understanding of C programs and tools built to
engineer C programs, such as compilers, debuggers, call graph
extractors, and translators. Most tools make no attempt to
analyze macro usage, but simply preprocess their input, which
results in a number of negative consequences; an analysis that
takes Cpp into account is preferable, but building such tools
requires an understanding of actual usage. Differences between
the semantics of Cpp and those of C can lead to subtle bugs
stemming from the use of the preprocessor, but there are no
previous reports of the prevalence of such errors. Use of C++ can
reduce some preprocessor usage, but such usage has not been
previously measured. Our data and analyses shed light on these
issues and others related to practical understanding or
manipulation of real C programs. The results are of interest to
language designers, tool writers, programmers, and software
engineers.
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell
Jul 23 '05 #1
4 1832
Thank you. After all, only those who write code are qualified to do
realistic research. This is valuable in quantifying a major source of
obscure defects.

Regards,
Z.
http://www.zhmicro.com
http://distributed-software.blogspot.com

Jul 23 '05 #2
Zorro wrote:
Thank you. After all, only those who write code are qualified to do
realistic research. This is valuable in quantifying a major source of
obscure defects.

Regards,
Z.
http://www.zhmicro.com
http://distributed-software.blogspot.com


I believe this is an expansion or variation of an article that appeared in
the 12th IEEE International Workshop on Program Comprehension (IWPC'04)
papers:

http://etheses.uwaterloo.ca/display.cfm?ethesis_id=390

Giving Meaning to Macros, by Mennie, Christopher

Abstract:
"With the prevalence of legacy C/C++ code, issues of readability and
maintainability have become increasingly important. When we consider the
problem of refactoring or migrating C/C++ code, we see the significant role
that preprocessor directives play. It is partially because of these
preprocessor directives that code maintenance has become extremely
difficult.

"This thesis describes a method of fact extraction and code manipulation to
create a set of transformations which will remove preprocessor directives
from the original source, converting them into regular C/C++ code with as
few changes as possible, while maintaining readability in the code. In
addition, some of the subtle issues that may arise when migrating
preprocessor directives are explored. After discussing the general
architecture of the test implementation, an examination of some metrics
gathered by running it on two software systems is given."

--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell
Jul 23 '05 #3
Thanks again. This is of particular interest to me because some time
ago I argued against the subtle uses of the preprocessor in connection
with BOOST initiative. I appreciate your bringing this matter up.

Regards,
Z.

Jul 23 '05 #4

"Steven T. Hatton" <ch********@ger mania.sup> wrote in message
news:6K******** ************@sp eakeasy.net...
pag.csail.mit.e du/~mernst/ pubs/c-preprocessor-tse2002.pdf

Abstract:
This is the first empirical study of the use of the C
macro preprocessor, Cpp. [snip] The intimate
connection between the C programming language and Cpp, and Cpp?s
unstructured transformations of token streams often hinder both
programmer understanding of C programs and tools built to
engineer C programs, such as compilers, debuggers, call graph
extractors, and translators. Most tools make no attempt to
analyze macro usage, but simply preprocess their input, which
results in a number of negative consequences; an analysis that
takes Cpp into account is preferable, but building such tools
requires an understanding of actual usage.


While we don't take into account all the uses of Cpp,
our DMS tool for processing C and C++ *do* handle a surprisingly
wide variety of source code containing Cpp directives,
and we manage to analyze/transform that code without
expanding or wrecking the directives. Yes, this is pretty
unique.

DMS has been used on major C and C++ reengineering tasks.

See http://www.semdesigns.com/Products/F...pFrontEnd.html.
--
Ira D. Baxter, Ph.D., CTO 512-250-1018
Semantic Designs, Inc. www.semdesigns.com
Jul 24 '05 #5

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

Similar topics

4
2261
by: beliavsky | last post by:
If I run PyChecker on the following program, stored in xtry.py, m = 10000000 k = 0 for i in xrange(m): k = k + i print k x = range(3) print x
3
3417
by: Daniele | last post by:
I have a 40 MB database in excel format. I need to use it in Analysis Services, I imported the data by DTS (Data Transformation Services), everything is working I can see the database, but I can't load it in the analysis services. I have to construct a cube but I can't see the database in any way I tried. Thank you I hope my message is quite clear Hope to find somebody that can answer me in Italian, but English is good
1
1601
by: BruceGilpin | last post by:
I was at a Microsoft sales presentation last week for the new version of SQL Server, Yukon. They had an extensive presentation on SQL Server and Reporting Services but didn't mention Analysis Services. When I asked about the future of the product the MS Sales rep couldn't give me any info. When I looked at the big product chart I got at the presntation, Analysis Services wasn't on it. There was just box refering to Reporting Services...
2
1843
by: Derek | last post by:
This isn't exactly a language question, but I'm curious if any of the veteran programmers out there could recommend a static analysis tool for C++. Specifically, I'm looking for something that can flag unreachable code, possible security errors like buffer overflows, and identify unused entities. It would also be great if said tool could identify any headers included un- necessarily, and perhaps compute some basic metrics. Are there...
0
1573
by: wwalkerbout | last post by:
Greetings, Although, this relates to Analysis Services administration, I thought I'd post it here in case someone with the administrative side of SQL Server who subscribes to this Group may also know Analysis Services and DSO as well. I have a need to run Analysis Services on a single Server instance, but obtaining its data from a SQL Server Cluster. I gather Analysis Services is not designed to work within a SQL Cluster. However, the
1
5897
by: Ben | last post by:
I have written a procedure which calls the CORREL function of Excel to run correlation analysis on two arrays, then populate a table with the resulting correlation coefficient. This process loops through several records and recordsets. The procedure works well for awhile (sometimes upwards of 10,000 times!), but then mysteriously begins populating "0" as the correlation coefficient (even though I know this to be inaccurate). Sometimes,...
0
1804
by: exits funnel | last post by:
Hello, I apologize if this question is a bit vague and slightly off topic but I couldn't find an Analysis Services and/or ODBO specific newsgroup. In any event, I'm trying to address an issue in some code I've inherited from a colleague who is on vacation and unfortunately, it deals with ODBO, COM and Analysis Services, three topics with which I'm pretty unfamiliar. Having said that here is the situation as best I can explain it: the...
0
1457
by: tavares | last post by:
--------------------------------------------------------------------------------------------------------------------------------------------- (Apologies for cross-posting) Symposium "Computational Methods in Image Analysis" National Congress on Computational Mechanics (USNCCM IX) San Francisco, CA, USA, July 22 - 26 2007 http://www.me.berkeley.edu/compmat/USACM/main.html We would appreciate if you could distribute this information by...
0
1208
by: tavares | last post by:
------------------------------------------------------------------------------------------------------------------------------------------- (Apologies for cross-posting) Symposium "Computational Methods in Image Analysis" National Congress on Computational Mechanics (USNCCM IX) San Francisco, CA, USA, July 22 - 26 2007 http://www.me.berkeley.edu/compmat/USACM/main.html We would appreciate if you could distribute this information by...
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10408
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
10137
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...
0
6895
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5561
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4346
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
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3026
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.