Help on the way to retrieve header file list

Hi

I am using module GetCompileUnitAtIndex to retrieve

Compilation unit. If I directly print Compile_unit.file

I can get all .c filenames without any .h filename.

If I use GetSupportFileAtIndex() to retrieve all supportfiles

And print out. I can get .h filename however, there

Are a lot of duplication.

Is there any better way to print all .c and .h filenames without

Duplication?

Thanks,

Yin

No. But you can take advantage of the fact that the basenames and directories returned from the SBFileSpec are uniqued C strings:

    const char *
    SBFileSpec::GetFilename() const;

    const char *
    SBFileSpec::GetDirectory() const;

So you might be able to use that to your advantage to help you unique these files into a std::set:

typedef std::set<std::pair<const char *, const char *>> PathSet;

PathSet unique_paths;

Then you can run through all files and do:

for (SBFileSpec cu_file : ...)
{
    unique_paths.insert(std::make_pair(cu_file.GetDirectory(), cu_file.GetFilename()));

    for (SBFileSpec support_file : ...)
  unique_paths.insert(std::make_pair(support_file.GetDirectory(), support_file.GetFilename()));

}

This should solve your problem for you?

Greg

Hi Greg,

Thank you for the quick answer. I will go ahead to
implement a pass to remove the redundancy in the list.

Thanks,

Yin