473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

An Empirical Analysis of CPP Use

pag.csail.mit.edu/~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 1813
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********@germania.sup> wrote in message
news:6K********************@speakeasy.net...
pag.csail.mit.edu/~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
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
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...
1
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...
2
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...
0
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...
1
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...
0
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...
0
by: tavares | last post by:
--------------------------------------------------------------------------------------------------------------------------------------------- (Apologies for cross-posting) Symposium...
0
by: tavares | last post by:
------------------------------------------------------------------------------------------------------------------------------------------- (Apologies for cross-posting) Symposium...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.