[petsc-dev] Reminder: *every* symbol with extern linkage *must* be namespaced

Shri abhyshr at mcs.anl.gov
Sat Mar 17 10:49:34 CDT 2012


I don't know namespacing but looks like its a C++ declaration that can be simulated in C either using prefixes or by using a struct. http://ejrh.wordpress.com/2012/01/24/namespaces-in-c/ . What's the prefered PETSc way of namespacing in C? Use the prefix 'Petsc'? Shri ----- Original Message -----
> What does namespaced mean exactly?
> On Mar 17, 2012, at 10:58 AM, Jed Brown wrote:
> > Every symbol (both functions and data) with extern linkage must be
> > namespaced to avoid link- or run-time conflicts when the user (or
> > any
> > other library to be used in the same application) defines their own
> > variable called "rankkey" or "actions" or "objects" or "ListCreate"
> > or
> > "createLevel", etc. No exceptions.
> > Either use static linkage or namespace the symbols. Some old code
> > was
> > sloppy about this (and needs to be fixed), but we really need to be
> > careful to never do this is new code.
> > You can build a libpetsc.a (--with-shared-libraries=0) and search
> > for
> > any defined symbols (T, B, R, C, D) that are not namespaced. Some
> > examples below.
> > pthread.c:
> > 00000000000004c5 T DoCoreAffinity
> > 0000000000000232 T FuncFinish
> > 0000000000000010 B MainThreadCoreAffinity
> > 0000000000000100 R ThreadAffinityPolicyTypes
> > 0000000000000008 B ThreadCoreAffinity
> > 0000000000000060 R ThreadSynchronizationTypes
> > 0000000000000004 C rankkey
> > 0000000000000018 B threadranks
> > plog.c:
> > 0000000000000000 B actions
> > 0000000000000010 B logActions
> > 0000000000000014 B logObjects
> > 0000000000000038 D maxActions
> > 000000000000003c D maxObjects
> > 0000000000000018 B numActions
> > 000000000000001c B numObjects
> > 0000000000000020 B numObjectsDestroyed
> > 0000000000000008 B objects
> > 0000000000000040 D traceblanks
> > 00000000000000d8 B tracefile
> > 00000000000000e0 B tracelevel
> > 0000000000000060 D tracespace
> > 00000000000000e8 B tracetime
> > ctetgen.c:
> > 000000000000ade7 T ArrayPoolCreate
> > 000000000000b979 T ArrayPoolDestroy
> > 000000000000b0cf T ArrayPoolGetBlock
> > 000000000000b6f7 T ArrayPoolNewIndex
> > 000000000000ac41 T ArrayPoolRestart
> > 0000000000006cfe T ListAppend
> > 00000000000082ec T ListClear
> > 00000000000069c7 T ListCreate
> > 00000000000077ad T ListDelete
> > 0000000000008491 T ListDestroy
> > 0000000000007ae2 T ListHasItem
> > 000000000000718e T ListInsert
> > 0000000000007ea0 T ListItem
> > 0000000000007cf5 T ListLength
> > 00000000000080c6 T ListSetItem
> > 00000000000096af T MemoryPoolAlloc
> > 000000000000a415 T MemoryPoolCreate
> > 0000000000009a9d T MemoryPoolDealloc
> > 000000000000a827 T MemoryPoolDestroy
> > 000000000000a1ed T MemoryPoolRestart
> > 0000000000009c6a T MemoryPoolTraversalInit
> > 0000000000009e6e T MemoryPoolTraverse
> > 0000000000008868 T QueueCreate
> > 0000000000009324 T QueueDestroy
> > 0000000000008c23 T QueueLength
> > 00000000000090b0 T QueuePop
> > 0000000000008dd5 T QueuePush
> > 0000000000003f06 T lu_decmp
> > 0000000000004303 T lu_solve
> > gamg.c/agg.c/geo.c/tools.c:
> > 0000000000000926 T createLevel
> > 0000000000000050 C gamg_setup_events
> > 00000000000054c6 T formProl0
> > 0000000000002989 T smoothAggs
> > 0000000000000629 T geo_mg_compare
> > 00000000000012f0 T getGIDsOnSquareGraph
> > 0000000000001292 T triangulateAndFormProl
> > 0000000000000629 T createSimpleGraph
> > 00000000000028fe T getDataWithGhosts
> > 0000000000001415 T scaleFilterGrap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120317/ce6a4f76/attachment.html>


More information about the petsc-dev mailing list