exporting all my classes of course goes against why you might use the -fvisibility=hidden flag so I'm not sure what the intention would be to use it once you export the world.
Here is my example source code. I tried it with/without the counter class having visibility set to default.
It fails either way.
Compile these with -fvisibility=hidden and the code fails to elaborate. Remove the flag and you get the output:
SystemC 2.3.2-Accellera --- Apr 28 2019 15:26:09
Copyright (c) 1996-2017 by all Contributors,
ALL RIGHTS RESERVED
reset active:count 0
reset active:count 0
reset active:count 0
enable active:count 1
enable active:count 2
enable active:count 3
enable active:count 4
// --------------------- sc_main.cc -----------------------------------------------
#include "counter.h"
int
__attribute__ ((visibility ("default"))) //<--- comment /uncomment line if desired
sc_main(int argc, char* argv[])
{
sc_signal<bool> reset, enable;
sc_signal<sc_uint<4>> count;
sc_time step(5.0, SC_NS);
sc_clock clk("clock", sc_time(5.0, SC_NS));
counter counter("counter");
counter.clock(clk);
counter.reset(reset);
counter.enable(enable);
counter.countOut(count);
reset = true;
enable = false;
sc_start(step);
sc_start(step);
reset = false;
enable = true;
sc_start(step);
sc_start(step);
sc_start(step);
sc_start(step);
return 0;
}
// ------------------------------------ counter.h ------------------------------------------------------------------
#pragma once
#include "systemc.h"
class
__attribute__ ((visibility ("default"))) //<--- comment /uncomment line if desired
counter: public sc_module
{
public:
sc_in_clk clock;
sc_in<bool> reset;
sc_in<bool> enable;
sc_out<sc_uint<4>> countOut;
SC_HAS_PROCESS(counter);
counter(const sc_core::sc_module_name& name);
void inc();
private:
sc_uint<4> count;
};
// -------------------------------------------- counter.cc ----------------------------------------------------------------------
#include <iostream>
#include "counter.h"
counter::counter(const sc_core::sc_module_name& name):
sc_module(name),
count(0)
{
SC_METHOD(inc);
sensitive << reset;
sensitive << clock.pos();
}
void counter::inc()
{
if (reset.read() == 1)
{
count = 0;
countOut.write(count);
std::cout << "reset active:count " << count << std::endl;
}
else if (enable.read() == 1)
{
count += 1;
countOut.write(count);
std::cout << "enable active:count " << count << std::endl;
}
}