C++ only


Generates unique names for static constructor/destructor file compilation units.


Read syntax diagramSkip visual syntax diagram        .-nounique-.
>>- -q--+-unique---+-------------------------------------------><


Unique names are generated with -qunique by encoding random numbers into the name of the static constructor and destructor functions. Default behavior is encoding the absolute path name of the source file in the constructor and destructor functions. If the absolute path name will be identical for multiple compilations (for example, if a make script is used), the -qunique option is necessary.

If you use -qunique, you must always link with all .o and .a files. Do not include an executable file on the link step.


Suppose you want to compile several files using the same path name, ensuring that static construction works correctly. A Makefile may generate the following steps:

sqlpreprocess file1.sql > t.C
  xlc++ -qunique t.C -o file1.o
rm -f t.C
sqlpreprocess file2.sql > t.C
  xlc++ -qunique t.C -o file2.o
rm -f t.C
  xlc++ file1.o file2.o

Following is a sample Makefile for the above example:

# rule to get from file.sql to file.o
.SUFFIXES:      .sql
       sqlpreprocess $< > t.C
       $(CCC) t.C -c $(CCFLAGS) -o $@
       rm -f t.C

Related information