Shop OBEX P1 Docs P2 Docs Learn Events
flexcc -c option — Parallax Forums

flexcc -c option

How does the flexcc -c option work? Can I use it just like GCC to create object files that can be placed in a library and later linked?

Comments

  • I just looked at a generated .o file and it just contains the same source as was in the .c file. I guess the -c option doesn't do anything except copy its input file to its output file. That works fine if I then just include the .o files in another command line for flexcc but what if I put them in a library? Does that also work?

  • @"David Betz" said:
    I just looked at a generated .o file and it just contains the same source as was in the .c file. I guess the -c option doesn't do anything except copy its input file to its output file. That works fine if I then just include the .o files in another command line for flexcc but what if I put them in a library? Does that also work?

    Define library. You mean an ar-style library file? I don't think that's supported at all. Is kindof pointless when its just the source. You really wouldn't want actual object files, anyways, that'd inhibit dead code elimination and cross-module inlining.

    The "FlexC special way" of doing libraries (see: the included standard library) is to use the _fromfile extension on function declarations to autoload the source file containing the function.

  • There's no ar tool yet. There is a "libtool" program that I kind of hacked together for my own purposes, but I don't distribute the binary (source code is in spin2cpp/libtool.c) that can generate a list of __fromfile declarations from a set of C files. That's how the libc.a that comes with FlexC was generated. It's not perfect, but it does kind of work.

    Making a "real" library tool with something like ar is on my TODO list, but it keeps getting pushed back due to other things. Under the hood flexspin will always want to compile the whole program at once. This allows some optimizations which wouldn't otherwise be available, and given the relatively small size that P2 programs have to be, it doesn't seem too outrageous.

  • Actually, it seems like ar could just be replaced by cat combining all of the sources into a single big source.

  • I don't think cat would work in the general case, since there could be conflicts between user symbols and symbols declared in the library. But it would work for many common purposes.

Sign In or Register to comment.