I've done this before with C (using gcc) and FPC. C++ would be a bit more tricky since there's name mangling involved; you'd have to wrap all the functions you want to call from Pascal code in 'extern "C" {}' blocks.

Basically I compiled the C code to .o files, and in my Pascal code I put all the functions I needed calling as cdecl (since the calling conventions have to match) - but you can also do it the other way, use "alias" (or was it "name"?) in Pascal code to force a link-name for a function, and then define it as extern in the C code. Either way, later on one can either use {$LINK} in the Pascal code, or the -k command-line option to let the linker know it must include the .o file in the executable. Note that this process requires FPC to build the executable. Should you want to compile some Pascal code, and then build the final executable with gcc, things may not be so simple.