On this page:
1.5History
top
up

1C Metaprogramming UtilitiesπŸ”— i

This package provides utilities for manipulating C programs.

1.1Getting StartedπŸ”— i

The easiest way to get started using the C metaprogramming utilities is with the main module:

(require c ) package: c-utils

This module provides everything in the entire package. Subsequent sections of this manual describe the functionality of the individual libraries included, which can also be required individually.

Examples:
> (define time.h
(struct tm([inttm_sec]
[inttm_min]
[inttm_hour]
[inttm_mday]
[inttm_mon]
[inttm_year]
[inttm_wday]
[inttm_yday]
[inttm_isdst]))))
(system-compiler #:include<>'("time.h")gcc )))
> (layout-offset (time 'tm)'tm_year)

20

Binary layout information is especially useful for interacting with the foreign library—see The Racket Foreign Interface. For example, the procedures ptr-ref and ptr-set! can be used to read and write from arbitrary addresses, which can be computed using layout information.

1.2Libraries Provided by this PackageπŸ”— i

This package includes:

1.3Known LimitationsπŸ”— i

The parser does not recognize the C preprocessor. I may attempt to implement the preprocessor in the future, but there’s no guarantee at this point.

The grammar does not support any extensions for GCC, MSVC, or any other specific C implementations. I intend to add support for these extensions on a by-need basis. Specific requests (as well as patches) are welcome.

External compilation is currently limited to GCC. I intend to add support for additional compilers on a by-need basis; patches are welcome.

1.4Feedback and Bug ReportsπŸ”— i

Before sending feedback or bug reports, please consult the current set of registered issues. If you cannot find your issue there, feel free to file a new bug report in the online issue database.

Any other feedback may be emailed to me, Dave Herman, at dherman@ccs.neu.edu.

1.5HistoryπŸ”— i

  • Version 0.1 (2009εΉ΄02月01ζ—₯) - Initial release. Reasonably usable for header extraction.

  • Version 0.2 (2009εΉ΄03月09ζ—₯) - Full C99 parser implemented.

  • Version 0.3 (2009εΉ΄03月31ζ—₯) - Some cleanup of the AST API.

  • Version 0.4 (2009εΉ΄09月16ζ—₯) - Fixed parser bug 202: the grammar should be complete now.

  • Version 0.5 (2012εΉ΄02月26ζ—₯) - Updated for Racket.

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /