-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds a new `CORK_INITIALIZER` macro, which you can use to declare a function that should be automatically executed at program startup time. Right now we only implement this macro on GCC, using the `constructor` function attribute.
- Loading branch information
Douglas Creager
committed
Dec 27, 2012
1 parent
6f2298f
commit 54b2395
Showing
7 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* -*- coding: utf-8 -*- | ||
* ---------------------------------------------------------------------- | ||
* Copyright © 2012, RedJack, LLC. | ||
* All rights reserved. | ||
* | ||
* Please see the COPYING file in this distribution for license | ||
* details. | ||
* ---------------------------------------------------------------------- | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include <libcork/core.h> | ||
|
||
CORK_INITIALIZER(init) | ||
{ | ||
printf("Initializer 1\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* -*- coding: utf-8 -*- | ||
* ---------------------------------------------------------------------- | ||
* Copyright © 2012, RedJack, LLC. | ||
* All rights reserved. | ||
* | ||
* Please see the COPYING file in this distribution for license | ||
* details. | ||
* ---------------------------------------------------------------------- | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include <libcork/core.h> | ||
|
||
CORK_INITIALIZER(init) | ||
{ | ||
printf("Initializer 2\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* -*- coding: utf-8 -*- | ||
* ---------------------------------------------------------------------- | ||
* Copyright © 2012, RedJack, LLC. | ||
* All rights reserved. | ||
* | ||
* Please see the COPYING file in this distribution for license | ||
* details. | ||
* ---------------------------------------------------------------------- | ||
*/ | ||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
We need to sort the output, since there's no guarantee about which order our | ||
initializer functions will run in. | ||
|
||
$ cork-initializer | sort | ||
Initializer 1 | ||
Initializer 2 |