bug-gperf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gperf] gperf. Use not in main.cpp


From: Bruno Haible
Subject: Re: [bug-gperf] gperf. Use not in main.cpp
Date: Sun, 21 Nov 2010 20:42:29 +0100
User-agent: KMail/1.9.9

Hello,

Pavel Klimenko wrote:
> I try to use gperf not in main.cpp. Is it possible?

Sure it is possible.

> Keep getting an error when compiling:
> "$ make
> g++ gperf.cpp perfecthash.hpp command_options.h cli_args.cpp cli_args.h
> -o use_gperf
> /tmp/ccZbB9sc.o: In function
> `Perfect_Hash::IsValidCommandLineOption(char const*, unsigned int)':
> cli_args.cpp:(.text+0x0): multiple definition of
> `Perfect_Hash::IsValidCommandLineOption(char const*, unsigned int)'
> /tmp/cc4IoMh8.o:gperf.cpp:(.text+0x0): first defined here
> collect2: ld returned 1 exit status
> make: *** [all] Error 1"
> 
> In attachment simple example.

The error comes from the fact that
  1) The generated class Perfect_Hash is not entirely inline
     (it has a non-inline member function IsValidCommandLineOption),
  2) You are including it in 3 places: once directly from the command line
     perfecthash.hpp, once from cli_args.h included by cli_args.cpp, and
     once from cli_args.h included by gperf.cpp.

This generated code is suitable for including in one and only one compilation
unit. Kind of a "private" include file of the code that will call
IsValidCommandLineOption.

Bruno



reply via email to

[Prev in Thread] Current Thread [Next in Thread]