Fossil Forum

makeheaders problem
Login

makeheaders problem

(1) By anonymous on 2020-07-21 09:53:05 [link] [source]

Hello,

Using the EXPORT keyword on a function definition with makeheaders seems to produce bad output. See the following example tested with the most recent makeheaders.c. Note that the functions marked EXPORT do not appear correctly in the output. If the EXPORT prefix is removed, the functions again appear in the output. Can anyone confirm if this is a bug, or if I am doing something wrong?

hello.c:

#include "hello.h"

EXPORT int hello(int a) {
  return 0;
}

EXPORT void bar() {
}

void baz() {
}

hello.h (generated):

/* This file was automatically generated.  Do not edit! */
#undef INTERFACE
void baz();
();
();
#define EXPORT

Thanks,

Alan

(2) By Stephan Beal (stephan) on 2020-07-21 10:08:37 in reply to 1 [link] [source]

Using the EXPORT keyword on a function definition with makeheaders seems to produce bad output.... Can anyone confirm if this is a bug, or if I am doing something wrong?

makeheaders isn't really one of our deliverables. It's an internal-use tool for fossil's build process and fossil doesn't need/use constructs like your EXPORT (which is a client-side macro, not a C keyword). A patch to add such a thing would be thoughtfully considered.

(3) By anonymous on 2020-07-21 10:34:58 in reply to 2 [link] [source]

Hello,

That makes sense that it is unsupported / for internal use only. The main reason I am writing here about it is that EXPORT is documented here:

https://fossil-scm.org/fossil/doc/trunk/src/makeheaders.html#H0010

so I assumed it would work. I have tested this with an older version of makeheaders from

http://web.archive.org/web/20100820061138if_/http://www.hwaci.com:80/sw/mkhdr/makeheaders.c

and it works with that version, so it appears this is indeed a regression. The oldest version of makeheaders.c in the Fossil tree also appears to have the bug. The next version available via archive.org at that url is

http://web.archive.org/web/20110704190405if_/http://www.hwaci.com:80/sw/mkhdr/makeheaders.c

which appears to be Fossil-derived, but the diff between that and the working archived version is not so big. I might see if I can make a patch, but no promises.

Thanks,

Alan

(4) By Stephan Beal (stephan) on 2020-07-21 11:03:57 in reply to 3 [link] [source]

https://fossil-scm.org/fossil/doc/trunk/src/makeheaders.html#H0010

Indeed, it's not behaving the way it's documented:

[stephan@lapdog:~/fossil/fossil/bld]$ cat foo.c
#include "foo.h"

EXPORT int foo(){
  return 0;
}
[stephan@lapdog:~/fossil/fossil/bld]$ ./makeheaders -H foo.c
();

The oldest version of makeheaders.c in the Fossil tree also appears to have the bug.

The oldest one in fossil is more than a decade old, so there's certainly been some divergence since then. The version of that file in fossil has never needed that flag, so it's unsurprising that it's fallen by the wayside.

http://www.hwaci.com:80/sw/mkhdr/makeheaders.c

which appears to be Fossil-derived,

Based on the March 2005 CVS header in the current version of that file (grabbed directly from hwaci, not archive.org), it seems to be the other way around: fossil's copy was probably initially derived from that one (or a close relative of it: hwaci is Richard's company and fossil is his project).

However, the latest copy from hwaci seems to have the same problem. The one from:

http://web.archive.org/web/20100820061138if_/http://www.hwaci.com:80/sw/mkhdr/makeheaders.c

doesn't compile as-is on current gcc because of printf format specifier errors and pointer-to-int casting errors, so i haven't tested that one. In any case, the -H flag seems to have been broken in or before 2005, before fossil inherited that file.

http://web.archive.org/web/20110704190405if_/http://www.hwaci.com:80/sw/mkhdr/makeheaders.c

That one compiles for me but has the same -H problem as the one in the fossil tree. (It also has the same CVS header as the older one which doesn't compile.)

i don't know how/whether the hwaci copy is maintained, but i know the fossil copy has been patched at least a few times in the past decade, so if you're going to patch one of them, that might be the best starting point.

(5) By anonymous on 2020-07-21 11:11:55 in reply to 4 [source]

Hello,

Thanks for digging into that. For whatever reason, my gcc on Debian seems to compile that first file, albeit with a lot of warnings, so that's how I was able to test it.

I've just done a quick debugging on the most recent Fossil version and I think I have a patch for you :)

--- makeheaders-orig.c	2020-07-21 04:03:56.181260353 -0700
+++ makeheaders.c	2020-07-21 04:04:54.729279157 -0700
@@ -1407,6 +1407,7 @@
         }
         if( skipOne ){
           pFirst = pFirst->pNext;
+          skipOne = 0;
           continue;
         }
         /* Fall thru to the next case */

Thanks,

Alan