473,652 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C module stub generator?

Does anyone know of a C stub generator? Prefer open-source and/or free.

This would parse the header .h file and create a .c file with stubbed
out functions.
This is handy for unit testing and interface and test driven
development.

thanks

Marco

Dec 11 '05 #1
5 3200
On 11 Dec 2005 06:23:37 -0800, in comp.lang.c , "Marco"
<pr**********@y ahoo.com> wrote:
Does anyone know of a C stub generator? Prefer open-source and/or free.

This would parse the header .h file and create a .c file with stubbed
out functions.
This is handy for unit testing and interface and test driven
development.


Not aware of anything that does precisely this, but it'd be trivial to
write in either C or Perl.

There also do exist perl scripts to generate stub functions from
Windows DLLs, and these operate by creating an intermediate file
essentially identical to a header. You could pull the perl down and
examine it.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 11 '05 #2
I hacked a stub generator:

visit comp.sources.d

look for cstub

Jan 7 '06 #3
Mark McIntyre wrote:
"Marco" <pr**********@y ahoo.com> wrote:
Does anyone know of a C stub generator? Prefer open-source
and/or free.

This would parse the header .h file and create a .c file with
stubbed out functions. This is handy for unit testing and
interface and test driven development.


Not aware of anything that does precisely this, but it'd be
trivial to write in either C or Perl.


Why bother? Copy the .h file to a .c file, strip the include
guards and and C++ guards, replace the #defines, and typedefs with
a #include of the .h, and start editing. In fact, copy the .h and
start editing.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Jan 7 '06 #4

Chuck F. wrote:
Mark McIntyre wrote:
"Marco" <pr**********@y ahoo.com> wrote:
Does anyone know of a C stub generator? Prefer open-source
and/or free.

This would parse the header .h file and create a .c file with
stubbed out functions. This is handy for unit testing and
interface and test driven development.


Not aware of anything that does precisely this, but it'd be
trivial to write in either C or Perl.


Why bother? Copy the .h file to a .c file, strip the include
guards and and C++ guards, replace the #defines, and typedefs with
a #include of the .h, and start editing. In fact, copy the .h and
start editing.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>


Jan 9 '06 #5
>
Why bother?


primary reason is to stub out code for unit testing that I am not
creating but need to use (like RTOS calls) or an existing HW interface

Jan 9 '06 #6

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

Similar topics

2
2329
by: Jeff Epler | last post by:
Hello. Recently, Generator Comprehensions were mentioned again on python-list. I have written an implementation for the compiler module. To try it out, however, you must be able to rebuild Python from source, because it also requires a change to Grammar. 1. Edit Python-2.3/Grammar/Grammar and add an alternative to the "listmaker" production: -listmaker: test ( list_for | (',' test)* )
1
1707
by: Adrien Di Mascio | last post by:
Hi all, While reading the email module documentation, I found an error in a small example given for the as_string() method of the Message class: Here is the given code : (URL : http://python.org/doc/current/lib/module-email.Message.html) from cStringIO import StringIO from email.Generator import Generator
17
2425
by: Andrae Muys | last post by:
Found myself needing serialised access to a shared generator from multiple threads. Came up with the following def serialise(gen): lock = threading.Lock() while 1: lock.acquire() try: next = gen.next() finally:
28
3684
by: Paul Rubin | last post by:
http://www.nightsong.com/phr/python/sharandom.c This is intended to be less predicable/have fewer correlations than the default Mersenne Twister or Wichmann-Hill generators. Comments are appreciated.
2
1986
by: James S | last post by:
Hi, Basically I've been fighting with this code for a few days now and can't seem to work around this problem. Included is the output, the program I use to get this error and the source code for my wrapper. This is acually part of the project, libxmlconf on sourceforge. The newest working version isn't there yet, and cvs is lagged by 6 hours or so. So if you think you want to have a try at this I can tgz the source for you. My...
5
1620
by: Roose | last post by:
Can I rely on the random.py module to produce the same series of numbers for future/past versions of Python, given the same seed? Can I rely on it across different architectures and operating systems? I looked at the docs and couldn't find this stated anywhere. My feeling is yes, but it's a fairly big claim so I want to make sure. R
1
3504
by: Irwin Friedman | last post by:
I'm a newbie and can't find any clues in the FAQ's I've searched through. I'm trying to use ActiveState Perl PPM to install a module (DBI) but I can't get very far. I get the following results: C:\Perl>ppm PPM - Programmer's Package Manager version 3.1. Copyright (c) 2001 ActiveState SRL. All Rights Reserved. Entering interactive shell. Using Term::ReadLine::Stub as readline library.
7
3915
by: Marco | last post by:
I am looking for an open-source or free tool that parses a C header file (.h) for a module and creates a .c file with the functions stubbed out ( ideally with dummy returns for non-void). This will be used for testing purposes. I have googled with little success. ( for a C++ class example google "stubgen"). Any leads would be appreciated.
10
1670
by: Tom Plunket | last post by:
I've got a bunch of code that runs under a bunch of unit tests. It'd be really handy if when testing I could supply replacement functionality to verify that the right things get called without those things actually getting called, since frequently those calls take a long time to execute and do things that, well, I don't really want to do. E.g. imagine you've got a routine which takes a filespec, generates a list of files, and copies...
0
8367
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...
0
8703
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
8467
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,...
1
6160
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
5619
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
4145
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
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
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
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.