473,543 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ 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 1716
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(Lis t1) it makes list1.
my_list{

list_1{elm1,elm 2,elm3},
list_2{elm4,elm 5,elm6},
list_3{elm5,elm 7,elm8},
}
Then i need a macro to add elements to specific list, so when i call ADD_ELM_TO_MYLI ST(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,e lm4) 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(Lis t1,elm2) it calls a function "action(elm 2)".
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(Lis t1) 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(nam e) \
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
3212
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 clarification on what 'macro' means. A Lisp macro is a way of modifying code when that code is first defined. It can rearrange the structure of the...
2
11095
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, I know how to do this. I'm preferring to keep the Excel instance invisible, but while the macro is running, it would be nice to see some sort of...
0
1607
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 macro who will be run when I click on a field (line) in
3
627
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 some type of pointer to the function? Also is there any benefit from placing a return at the end of a function which returns void? Thanks for any...
6
16425
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 I have a problem about the extract call graph from statice C source code , not from binary. I have try to use cscope and write some perl script...
7
2347
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
3510
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 objExcel = New Excel.Application objExcel.Workbooks.Open(FileName:="c:\test.xls", ReadOnly:=True) objExcel.Run("test.xls!test.test")
2
3485
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
2075
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
8908
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 function macro? Does it get passed in whole, or split into smaller parts like so:
0
7408
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7590
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7735
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7347
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5885
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5271
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3391
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
636
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.