473,465 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

macro to call lists

4 New Member
Hej Guys
I have problem to make some macros to my own project I want to make some
Macro which it can make a several list automatically as example:
Pseudo code:
#define A 0x01
#define B 0x02
#define C 0x04
Etc..

#define ENABEL_A 1
#define ENABEL_B 0
#define ENABEL _C 2
etc…

If (ENABEL_A == 1 ) ADD_TO_LIST_1(A);
else ADD_TO_LIST_2(A);
etc…

result shud bee

LIST_1 {A,B,C,D}
LIST_2 {B,C,D,F}
LIST_3 {E,F,D,G} etc….

And when I call another macro RUN_TRUE_LIST_1

It should runs true each list and call a function like:
Calling(A);
calling(B);
calling (C); etc.

So first a macro to make my lists
Second a macro to runs trues those lists. Please help me.
Jan 17 '12 #1
7 1715
johny10151981
1,059 Top Contributor
What is the problem again?
Jan 18 '12 #2
donbock
2,426 Recognized Expert Top Contributor
What language are you using?
Jan 18 '12 #3
sim fasaei
4 New Member
Im using C and the problem is :
Jan 18 '12 #4
sim fasaei
4 New Member
Sorry about last message her is the problem?

I need a macro to make my_list, so when i call MAKE_MYLIST(List1) it makes list1.
my_list{

list_1{elm1,elm2,elm3},
list_2{elm4,elm5,elm6},
list_3{elm5,elm7,elm8},
}
Then i need a macro to add elements to specific list, so when i call ADD_ELM_TO_MYLIST(List1,elm4) it adds elm4 to List_1.
And i need a macro to removes elements from specific list, so when i call REMOVE_ELM_FROM_MYLIST(List1,elm4) it removes elm4 from List_1.
Then i need a macro to put an element from random list as parameter in a function , so when I call ACT_ON_THIS(List1,elm2) it calls a function "action(elm2)".
Jan 18 '12 #5
donbock
2,426 Recognized Expert Top Contributor
Do you expect MAKE_MYLIST to be called from executable code or do you expect this macro to expand into into a variable definition with an initializer?

I need a macro to make my_list, so when i call MAKE_MYLIST(List1) it makes list1.
Expand|Select|Wrap|Line Numbers
  1. my_list{
  2. list_1{elm1,elm2,elm3},
  3. list_2{elm4,elm5,elm6},
  4. list_3{elm5,elm7,elm8},
  5. }
Are you sure? The macro expansion you show here is not valid C.

Some further questions:
  • What is the data type for my_list?
  • How did the macro know to use the name my_list?
  • How did the macro know there were three items, and that they were named list_1, list_2, list_3?
  • How did the macro know there were three subitems for each item, and how did it know what their names were?

And the big question -- why do you wish to do this with macros instead of C instructions?
Jan 19 '12 #6
sim fasaei
4 New Member
Iexpect this macro to expand into into a variable definition with an initializer:


enum{
elm1=1,
elm2,
elm3,
elm4,
.
.
.
last_elm
} MY_ELM_ID


typedef struct
{
MY_ELEM_ID lists[];
} MY_ELM_LIST;

#define MAKE_MYLIST(name) \
const MY_ELM_LIST name[] = {

};
And yes thats a god question why not C?
My intention was to make those lists or list at compiling time, so I easily can add or removes list\lists or elements from a header file.
let us sig like a group of switches.
Jan 19 '12 #7
donbock
2,426 Recognized Expert Top Contributor
list_1, list_2, and list_3 from your reply #5 correspond to that description of MAKE_MYLIST.
  • But where did my_list come from? It is an array of arrays.
  • How did the macro know how many elms to put in each list?
  • How did the macro know which elms to put in each list?
I can't be sure until I understand exactly what you're trying to do, but I suspect you would find it easier to accomplish this at execution time. Take a look at the Arrays Revealed article to see how to dynamically allocate a one-dimensional or two-dimensional array. (You will have to replace the C++ new keyword with a call to the malloc library function.)
Jan 19 '12 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a...
2
by: Mrs Howl | last post by:
I don't know if there's even a way to do what I want. I click on a button in an Access form, and it opens an instance of Excel, and opens a workbook and runs a macro that's in it. So far, fine,...
0
by: samuel | last post by:
Hi I wrote a macro in MS Access 2000. This is a .adp link on SQL server tables. I have 2 forms: script_selection & Form3 Form3 include 2 important fields: CD & line I want to write a...
3
by: Andrew | last post by:
Hello, Is it bad practice to use a function as a parameter of a macro? Will the compiler create a full copy of the function's machine code for each invocation of the macro? Or does it create...
6
by: Xing Xu | last post by:
Hi guiders, sorry , since I don't know which group suit for this question,I just post this question at these group. As we know , we can get the run-time call graph by some proved tools . now...
7
by: Karim Thapa | last post by:
I defined a MACRO 'removebrace' as following #define removebrace(x) x main() { ... MyFunc(1, 2, removebrace("hello", 5, 6));
2
by: cr113 | last post by:
I just upgraded from Office 2000 to Office 2003. My VB.NET Excel macro calls don't work any longer. Here is how I make my Excel macro call from VB.NET: Dim objExcel as Excel.Application ...
2
by: srinu.fsl | last post by:
there's a MACRO call : MACRO1(cnf) and its expansion is : #define MACRO1(cnf) (((cnf) != TRUE)? (CLEANUP(FAIL)):(err = SUCCESS)); #define CLEANUP(a)
5
by: anushhprabu | last post by:
# include <stdio.h> # define MYMAC(MY) MY //Macro Function void main() { char s="3+2-(4*1)/5"; printf("Result : %f",MYMAC(s)); ??Macro Call }
5
by: TJ | last post by:
I'd like to know how the preprocessor treats curly braces, as compared to how it treats parentheses. What happens if I pass this: { a_function( arg1, arg2, arg3 ) } as an argument to a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.