how to use namespace

I had developed file ll_namespace.h and put it in to includes in Eclipse

namespace ll_namespace
{
struct ll_pkt_struct
{
sc_uint<8> preamble;
sc_uint<32> access_addr;
sc_uint <16> header;
sc_uint <8> * payload;
sc_uint<24> crc;
};

struct s_ll_adv_param
{
sc_uint<16> adv_interval_min;
sc_uint<16> adv_interval_max;
sc_uint<8> adv_type;
sc_uint<8> own_addr_type;
sc_uint<8> dir_addr_type;
sc_uint<48> dir_addr;
sc_uint<8> adv_ch_map;
sc_uint<8> adv_fltr_policy;
};
}

Now i had to use the structures of this file in another file ll_cam.cpp
So how can i access namespace in ll_cam.cpp?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 // ll_namespace.h

namespace ll_namespace
{
struct ll_pkt_struct
{
sc_uint<8> preamble;
sc_uint<32> access_addr;
sc_uint <16> header;
sc_uint <8> * payload;
sc_uint<24> crc;
};

struct s_ll_adv_param
{
sc_uint<16> adv_interval_min;
sc_uint<16> adv_interval_max;
sc_uint<8> adv_type;
sc_uint<8> own_addr_type;
sc_uint<8> dir_addr_type;
sc_uint<48> dir_addr;
sc_uint<8> adv_ch_map;
sc_uint<8> adv_fltr_policy;
};
}



1
2
3
4
5
6
7
8
9
 // ll_cam.cpp
#include "ll_namespace.h"
using pkt = ll_namespace::ll_pkt_struct;
using adv = ll_namespace::ll_adv_param;

int main() {
    pkt pkt_struct;
    adv adv_param;
}
As long as you #include "ll_namespace.h" you would use it by doing the following:
1
2
3
4
5
6
int main() {
   ll_namespace::ll_pkt_struct myStruct;
   myStruct.preamble = 5; // whatever you would assign it to normally.

   return 0;
}
Topic archived. No new replies allowed.