What does extern "C" :: means?

I’m learning how to write a Pass as a plugin with new Pass manager. I understand what extern “C” means in C++ context. However, what does the extern “C”:: mean in the following codes? It seemingly deems extern “C” as a namespace. I have tried to Google it but nothing useful was found. Could anyone please what extern “C” :: means and what is the difference between extern “C” and extern “C” :: ? Any reference link and material would be helpful. Thanks.

#include "CountIR.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/Debug.h"

#define DEBUG_TYPE "countir"

STATISTIC(NumOfInst,"Number of instructions.");
STATISTIC(NumOfBB,"Number of basic blocks.");

llvm::PreservedAnalyses CountIRPass::run(
        llvm::Function& F,llvm::FunctionAnalysisManager& AM){
            for(llvm::BasicBlock& BB: F){
                ++NumOfBB;
                for(llvm::Instruction& I:BB){
                    (void)I;
                    ++NumOfInst;
                }
            }
            return llvm::PreservedAnalyses::all();
}

bool PipelineParsingCB(llvm::StringRef Name,llvm::FunctionPassManager& FPM,llvm::ArrayRef<llvm::PassBuilder::PipelineElement>){
    if(Name=="countir"){
        FPM.addPass(CountIRPass());
        return true;
    }
    return false;
}

void RegisterCB(llvm::PassBuilder& PB){
    PB.registerPipelineParsingCallback(PipelineParsingCB);
}

//return the Pass entity from a function.
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK llvmGetPassPluginInfo(){
    return {LLVM_PLUGIN_API_VERSION,"CountIR","v0.1",RegisterCB};
}

The :: is a part of the name of the return type. This is still extern "C" ret_type llvmGetPassPluginInfo() {...}

Thanks for your reply. You mean the ret_type is ::llvm::PassPluginLibraryInfo? I don’t pretty understand why a class can be prefixed with :: . Do you have any technique detail references or other links? Or, does such techique specification have any name or terms to be described? Thanks again!

https://en.cppreference.com/w/cpp/language/qualified_lookup

If there is nothing on the left hand side of the :: , the lookup considers only declarations made in the global namespace scope (or introduced into the global namespace by a using declaration). This makes it possible to refer to such names even if they were hidden by a local declaration:

1 Like