[R-SIG-Mac] kinship

Paul Roebuck roebuck at wotan.mdacc.tmc.edu
Sun Oct 23 09:35:15 CEST 2005


On Sat, 22 Oct 2005, Andrew Beckerman wrote:

> I am trying to install the package "kinship", only available through
> source.  The package seems to do well until the very end, where a
> multiple definitions error crops up (see below).   A previous post
> and response from B. Ripley suggested the following:
>
> "You need to change coxfit6.h to have the object extern in all but
> one of the files it is included in. That is a peculiarity of MacOS X."

It's not exactly what I would call peculiar ("odd"); rather
it simply enforces that a given variable definition only
occurs once.

> Any advice on how to accomplish this?  Is it in the works with
> regards to packaging a binary?

One approach might be to create a single file named
"foo_globals.h" (given project named "foo") with the
contents something like the following:

#ifndef FOO_GLOBALS_H
#define FOO_GLOBALS_H 1

#include <sys/types.h>

#ifdef DEFINE_GLOBALS
#define EXTERNALREF
#else
#define EXTERNALREF extern
#endif

/*
 * Global Variables
 */
EXTERNALREF unsigned gNumSims;

#endif /* FOO_GLOBALS_H */


All source files in your project that access the global variables
would #include "foo_globals.h" (possibly indirectly). For an
application, I would nominally have a minimal project header
(appropriately named "foo.h") which contained the following:

#ifndef FOO_H
#define FOO_H 1

#include "foo_types.h"   /* project-specific typedefs */
#include "foo_globals.h"

#endif /* FOO_H */


In the source file containing the main() function
(normally "foo.c"), you would prepend the preprocessor value
prior to including any project-specific headers.

#include <stdio.h>
#include <stdlib.h>
#define DEFINE_GLOBALS 1
#include "foo.h"

int main(int argc, char *argv[])
{
...
}

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)



More information about the R-SIG-Mac mailing list