amitk3553 Posted November 20, 2013 Report Posted November 20, 2013 Hello, In comments there are questions, answer please...Actually I have to pass parameter from the top. #define test testcase_001 //have to pass parameter, is this right way? #include "testcases/test.cpp" //could I pass parameterized value here?class hci_test{ public: unsigned char* host_hci_pkt_arr; unsigned int address; test test_case; //could I make object handle like this(using parameter here)?? hci_test() //constructor { host_hci_pkt_arr = new(nothrow) unsigned char [20]; host_hci_pkt_arr[0] = test_case.host_hci_pkt_arr[0]; host_hci_pkt_arr[1] = test_case.host_hci_pkt_arr[1]; }}; After compilation compiler throwing errors :2nd line: error: testcases/test.cpp: No such file or directory:9th line: error: ISO C++ forbids declaration of ‘testcase_001’ with no type:9th line: error: ISO C++ forbids declaration of ‘test_case’ with no type and when I comment first line of code and in 2nd and 9th line, instead of test, I write testcase_001, then it works fine means problem is in passing value from the top. So let me know the corrections required in it if any or some other way to achieve this kind of passing parameters or values from the top, as #define is just used for aliasing or can do the work like parameter? Please respond Thankscam Annossyenudge 1 Quote
amitk3553 Posted November 21, 2013 Author Report Posted November 21, 2013 I think its not possible to pass some parameter from here, it seems compiler is not picking value of test in 2nd line? Need to add following line in makefile to implement the desired functionality? #include "testcases/test.cpp" Regards cam Quote
dakupoto Posted November 22, 2013 Report Posted November 22, 2013 Hello, In comments there are questions, answer please...Actually I have to pass parameter from the top. #define test testcase_001; //have to pass parameter, is this right way? #include "testcases/test.cpp" //could I pass parameterized value here?class hci_test { public: unsigned char* host_hci_pkt_arr; unsigned int address; test test_case; //could I make object handle like this(using parameter here)?? hci_test() //constructor { host_hci_pkt_arr = new(nothrow) unsigned char [20]; host_hci_pkt_arr[0] = test_case.host_hci_pkt_arr[0]; host_hci_pkt_arr[1] = test_case.host_hci_pkt_arr[1]; } }; After compilation compiler throwing errors :2nd line: error: testcases/test.cpp: No such file or directory :9th line: error: ISO C++ forbids declaration of ‘testcase_001’ with no type :9th line: error: ISO C++ forbids declaration of ‘test_case’ with no type and when I comment first line of code and in 2nd and 9th line, instead of test, I write testcase_001, then it works fine means problem is in passing value from the top. So let me know the corrections required in it if any or some other way to achieve this kind of passing parameters or values from the top, as #define is just used for aliasing or can do the work like parameter? Please respond Thankscam Hello Sir, Please get hold of a good C++ reference and read through it. You are writing code for HCL, and asking on the forum whether a declaration in your C++ code is valid ? test test_case; //could I make object handle like this(using parameter here)?? Are you sure that class 'test' has a no arguments constructor ? Where are you creating an object of type 'test' ? Please try to correct the following: testcases/test.cpp: No such file or directory I am afraid no one else can help debug your code, without any access to all your classes. Quote
amitk3553 Posted November 22, 2013 Author Report Posted November 22, 2013 hello dakupoto, this piece of code i had used as tescase in verification environment(SystemC and TLM) for testing of systemC design of an IP. in C++, these syntax are present, but I just want to know could i use them as I was saying. I just have to pass parameter from the top. If i put testcase_001(file name) in place of test, it works fine testcases/test.cpp: No such file or directory but I want to pass different test cases by just passing testcase's name in place of name in #define test name thats why I was asking can i do all these things to achieve desired scenario. and what does mean by HCL? Thanks cam Quote
dakupoto Posted November 23, 2013 Report Posted November 23, 2013 hello dakupoto, this piece of code i had used as tescase in verification environment(SystemC and TLM) for testing of systemC design of an IP. in C++, these syntax are present, but I just want to know could i use them as I was saying. I just have to pass parameter from the top. If i put testcase_001(file name) in place of test, it works fine testcases/test.cpp: No such file or directory but I want to pass different test cases by just passing testcase's name in place of name in #define test name thats why I was asking can i do all these things to achieve desired scenario. and what does mean by HCL? Thanks cam Hello Sir. Let us clear the confusion here. May I suggest the following -- very widely used in both C++/ SystemC. 1. Put all test case classes in a ".h" file. When you want to use say "testcase_001" in a "*.cpp" file, just use include the appropriate header file (that is the *.h file with the test case classes) Will always work. 2. Make sure that each test case class has a no arguments constructor. 3. When you want to create an instance of a test case class, just do so by invoking the no arguments constructor. 4. If you use the 'new' operator to create an array, please use a "delete [] <arrayname>;" in the class destructor. You will save yourself lots of trouble and misery by staying away from the new and delete. 5. Please use a destructor in each class Hope that helps. amitk3553 1 Quote
amitk3553 Posted November 25, 2013 Author Report Posted November 25, 2013 Thanks dakupoto, I don't understood the meaning of following two lines, it means i cannot use hci_test() as i used in above code?Please throw some light on it. 2. Make sure that each test case class has a no arguments constructor. 3. When you want to create an instance of a test case class, just do so by invoking the no arguments constructor. Regards cam Quote
apfitch Posted November 25, 2013 Report Posted November 25, 2013 If you're happy to use a Gnu extension with gcc, you can use a "computed include", e.g. #define fred "testcases/testcase_001.cpp" #include fred However then you'd have to also write #define test testcase_001 to make the code compile when it declares the class. Perhaps you can do something like #define test testcase_001 #define testinc "testcases/#test" #include testinc (again gnu only) regards Alan amitk3553 and maehne 2 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.