Search Results

Search found 1608 results on 65 pages for 'declaration'.

Page 8/65 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Initializing an array after declaration

    - by robUK
    Hello, gcc 4.4.3 c89 I have the following code as a sample of what I am trying to do. I don't know the actual size of the array, until I enter the function. However, I don't think I can set the array size after I have declared it. I need it global as some other functions will need to access the device names. Many thanks for any suggestions, /* global */ char *devices_names[]; void fill_devices(size_t num_devices) { devices_names[num_devices]; /* start filling */ }

    Read the article

  • Initializing a array after declaration

    - by robUK
    Hello, gcc 4.4.3 c89 I have the following code as a sample of what I am trying to do. I don't know the actual size of the array, until I enter the function. However, I don't think I can set the array size after I have declared it. I need it global as some other functions will need to access the device names. Many thanks for any suggestions, /* global */ char *devices_names[]; void fill_devices(size_t num_devices) { devices_names[num_devices]; /* start filling */ }

    Read the article

  • Strange macro declaration in C

    - by Andrey Atapin
    Exploring libusb-1.0.9 source code, I have found such line (./os/poll_windows.c:78): #define CHECK_INIT_POLLING do {if(!is_polling_set) init_polling();} while(0) As for me this is the same like: #define CHECK_INIT_POLLING if(!is_polling_set) init_polling(); Is there any reason to loop that expression? UPDATE: I couldn't still realize what'd be wrong after the answers, and the following example helped: #include <stdio.h> #define TEST if(test) foo(); #define TEST_DO do { if(test) foo(); } while(0) int test = 1; void foo() { printf("%s", "Foo called"); } int main(int argc, char** argv) { if(argc > 1) TEST_DO; /* LINE 12 */ else printf("%s", "skipping..."); return 0; } If you put TEST at line 12, a compiler will give an error "error: ‘else’ without a previous ‘if’". Hope, this will help someone.

    Read the article

  • Force the use of interface instead of concrete implementation in declaration (.NET)

    - by gammelgul
    In C++, you can do the following: class base_class { public: virtual void do_something() = 0; }; class derived_class : public base_class { private: virtual void do_something() { std::cout << "do_something() called"; } }; The derived_class overrides the method do_something() and makes it private. The effect is, that the only way to call this method is like this: base_class *object = new derived_class(); object->do_something(); If you declare the object as of type derived_class, you can't call the method because it's private: derived_class *object = new derived_class(); object->do_something(); // --> error C2248: '::derived_class::do_something' : cannot access private member declared in class '::derived_class' I think this is quite nice, because if you create an abstract class that is used as an interface, you can make sure that nobody accidentally declares a field as the concrete type, but always uses the interface class. Since in C# / .NET in general, you aren't allowed to narrow the access from public to private when overriding a method, is there a way to achieve a similar effect here?

    Read the article

  • function declaration

    - by robUK
    Hello, gcc 4.1.2 c89 I am reviewing some code and I have come across the following function. I have never seen a function declared like this before. There are no data types for the paraemeters. My best guess is that the function is using a list of data types separated by semi-colons. The return type seems to be returning a function with those parameters. However, the read function is not defined anywhere. What is the advantage and purpose of declaring a function like this? Many thanks for any advice, int my_read(fd, ptr, cnt) int fd; char *ptr; unsigned cnt; { printf("Read\n"); return(read(fd, ptr, cnt)); }

    Read the article

  • Class Declaration in C++

    - by ML
    What does it mean when a class is declared like this: class CP_EXPORT CP_Window : public CP_Window_Imp What is the CP_EXPORT portion? What does it mean/imply?

    Read the article

  • Accessing controls of .aspx file in .aspx.cs without any declaration.!!??

    I am able to access the controls of ".aspx" file in ".aspx.cs" directly without any declaration in ".aspx.cs" or in designer.cs. How is this possible? This is happeing only if I open website as using File System. Create a new ASP.NET web site application with Visual Studio 2008. So following three files will be created automatically              "Default.aspx",              "Default.aspx.cs"              "Default.designer.cs" Now Delete "Default.designer.cs" perminently. Just create a button in Default.aspx file    <asp:Button runat="server" Text="Save Plan" ID="btnSave" />   Close the Solution and open the website as File System.               File -> Open Web Site -> File System -> Select Web Site Folder and Open the project.                   Now btnSave is automatically recognized in Default.aspx.cs without any declaration in Default.aspx.cs as bellow                            System.Web.UI.WebControls.Button btnSave; How btnSave is being recognized by .cs file without defining it anywhere as an object of System.Web.UI.WebControls.Button? Note: This happens only if you open Web Site from File System.           and No Declaration at all for btnSave. Please refer this article on this. span.fullpost {display:none;}

    Read the article

  • Accessing controls of .aspx file in .aspx.cs without any declaration.!!??

    I am able to access the controls of ".aspx" file in ".aspx.cs" directly without any declaration in ".aspx.cs" or in designer.cs. How is this possible? This is happeing only if I open website as using File System. Create a new ASP.NET web site application with Visual Studio 2008. So following three files will be created automatically              "Default.aspx",              "Default.aspx.cs"              "Default.designer.cs" Now Delete "Default.designer.cs" perminently. Just create a button in Default.aspx file    <asp:Button runat="server" Text="Save Plan" ID="btnSave" />   Close the Solution and open the website as File System.               File -> Open Web Site -> File System -> Select Web Site Folder and Open the project.                   Now btnSave is automatically recognized in Default.aspx.cs without any declaration in Default.aspx.cs as bellow                            System.Web.UI.WebControls.Button btnSave; How btnSave is being recognized by .cs file without defining it anywhere as an object of System.Web.UI.WebControls.Button? Note: This happens only if you open Web Site from File System.           and No Declaration at all for btnSave. Please refer this article on this. span.fullpost {display:none;}

    Read the article

  • Conflicting return types

    - by Adi
    I am doing a recursive program and I am getting an error about conflicting types: void* buddyMalloc(int req_size) { // Do something here return buddy_findout(original_index,req_size); // This is the recursive call } void *buddy_findout(int current_index,int req_size) { char *selected = NULL; if(front!=NULL) { if(current_index==original_index) { // Do something here return selected; } else { // Do Something here return buddy_findout(current_index+1,req_size); } } else { return buddy_findout(current_index-1,req_size); } } Error: buddy.c: At top level: buddy.c:76: error: conflicting types for ‘buddy_findout’ buddy.c:72: note: previous implicit declaration of ‘buddy_findout’ was here Please note the file buddy.c in which I am defining this does not contain main and is linked with several other .c files.

    Read the article

  • C++ MTL Library dimension.h bug?

    - by avanwieringen
    I've installed MTL on my Fedora Core 12 x64 system, but when building an application I get the following error: In file included from /usr/local/include/mtl/matrix.h:41, from /usr/local/include/mtl/mtl.h:40, from ltiSystem.hxx:4, from strTools.hxx:4, from ff.cxx:3: /usr/local/include/mtl/envelope2D.h:72: error: declaration of ‘typedef struct mtl::twod_tag mtl::envelope2D<T>::dimension’ /usr/local/include/mtl/dimension.h:19: error: changes meaning of ‘dimension’ from ‘class mtl::dimension<typename mtl::dense1D<T, 0>::size_type, 0, 0>’ make[1]: *** [ff.o] Error 1 Which would imply an error in MTL. I have changed to different MTL versions and the problem persists, but on Google there is no proper answer. I use the g++ compiler. Does anyone have a clye?

    Read the article

  • c++ : list(vector) definition with array

    - by Meloun
    I have Class Email, there is parameter "bcc" in her construktor. Its actually list of emails for copies. There is no fixed number of these emails and later i have to have possibility to extend this list. //construktor prototype Email::Email(vector<string> bcc) So i want to use type vector or list for that and function push_back(). How can i make a new instance with bcc emails? I need actually declaration with definition for my list. I've found this definition with iterator for integer type: int myints[] = {16,2,77,29}; Email myEmail(vector<int> (myints, myints + sizeof(myints) / sizeof(int) )); , but its not very user friend and i need it with strings. Is there something like this? Email myEmail(vector<string> ("first","second","third"));

    Read the article

  • Useless variable name in C struct type definition

    - by user1210233
    I'm implementing a linked list in C. Here's a struct that I made, which represents the linked list: typedef struct llist { struct lnode* head; /* Head pointer either points to a node with data or NULL */ struct lnode* tail; /* Tail pointer either points to a node with data or NULL */ unsigned int size; /* Size of the linked list */ } list; Isn't the "llist" basically useless. When a client uses this library and makes a new linked list, he would have the following declaration: list myList; So typing llist just before the opening brace is practically useless, right? The following code basically does the same job: typedef struct { struct lnode* head; /* Head pointer either points to a node with data or NULL */ struct lnode* tail; /* Tail pointer either points to a node with data or NULL */ unsigned int size; /* Size of the linked list */ } list;

    Read the article

  • Xen 4.2 on CentOs 6.3 : can't compile a libvirt 0.9.10 xen-activated?

    - by Frederic
    I followed that tutorial for Xen 4.2 on CentOs 6.3. http://www.howtoforge.com/virtualization-with-xen-on-centos-6.3-x86_64-paravirtualization-and-hardware-virtualization When building a new libvirt package with rpmbuild -bb libvirt.spec I get that error : CC libvirt_driver_libxl_la-libxl_conf.lo In file included from libxl/libxl_conf.c:43: libxl/libxl_conf.h:61: error: field 'ctx' has incomplete type libxl/libxl_conf.h:80: error: field 'ctx' has incomplete type libxl/libxl_conf.h:81: error: expected specifier-qualifier-list before 'libxl_waiter' libxl/libxl_conf.c: In function 'libxlMakeDomCreateInfo': libxl/libxl_conf.c:365: warning: implicit declaration of function 'libxl_init_create_info' [-Wimplicit-function-declaration] libxl/libxl_conf.c:365: warning: nested extern declaration of 'libxl_init_create_info' [-Wnested-externs] libxl/libxl_conf.c:367: error: 'libxl_domain_create_info' has no member named 'hvm' libxl/libxl_conf.c:383: warning: implicit declaration of function 'libxl_domain_create_info_destroy' [-Wimplicit-function-declaration] libxl/libxl_conf.c:383: warning: nested extern declaration of 'libxl_domain_create_info_destroy' [-Wnested-externs] libxl/libxl_conf.c: In function 'libxlMakeDomBuildInfo': libxl/libxl_conf.c:406: warning: implicit declaration of function 'libxl_init_build_info' [-Wimplicit-function-declaration] libxl/libxl_conf.c:406: warning: nested extern declaration of 'libxl_init_build_info' [-Wnested-externs] libxl/libxl_conf.c:408: error: 'libxl_domain_build_info' has no member named 'hvm' [...] Do you know what I need to install or change to pass that step?

    Read the article

  • Make function declarations based on function definitions

    - by Clinton Blackmore
    I've written a .cpp file with a number of functions in it, and now need to declare them in the header file. It occurred to me that I could grep the file for the class name, and get the declarations that way, and it would've worked well enough, too, had the complete function declaration before the definition -- return code, name, and parameters (but not function body) -- been on one line. It seems to me that this is something that would be generally useful, and must've been solved a number of times. I am happy to edit the output and not worried about edge cases; anything that gives me results that are right 95% of the time would be great. So, if, for example, my .cpp file had: i2cstatus_t NXTI2CDevice::writeRegisters( uint8_t start_register, // start of the register range uint8_t bytes_to_write, // number of bytes to write uint8_t* buffer = 0) // optional user-supplied buffer { ... } and a number of other similar functions, getting this back: i2cstatus_t NXTI2CDevice::writeRegisters( uint8_t start_register, // start of the register range uint8_t bytes_to_write, // number of bytes to write uint8_t* buffer = 0) for inclusion in the header file, after a little editing, would be fine. Getting this back: i2cstatus_t writeRegisters( uint8_t start_register, uint8_t bytes_to_write, uint8_t* buffer); or this: i2cstatus_t writeRegisters(uint8_t start_register, uint8_t bytes_to_write, uint8_t* buffer); would be even better.

    Read the article

  • forward declare typedef'd struct

    - by Steve
    I can't figure out how to forward declare a windows struct. The definition is typedef struct _CONTEXT { .... } CONTEXT, *PCONTEXT I really don't want to pull into this header, as it gets included everywhere. I've tried struct CONTEXT and struct _CONTEXT with no luck (redefinition of basic types with the actuall struct in winnt.h.

    Read the article

  • Two classes and inline functions

    - by klew
    I have two classes and both of them uses some of the other class, on example: // class1.h class Class1; #include "class2.h" class Class1 { public: static Class2 *C2; ... }; // class2.h class Class2; #include "class1.h" class Class2 { public: static Class1 *C1; ... }; And when I define it like in example above, it works (I also have some #ifndef to avoid infinite header recurency). But I also want to add some inline functions to my classes. And I read here that I should put definition of inline function in header file, because it won't work if I'll put them in cpp file and want to call them from other cpp file (when I do it I get undefined reference during linking). But the problem here is with something like this: // class1.h ... inline void Class1::Foo() { C2->Bar(); } I get error: invalid use of incomplete type ‘struct Class2’. So how can I do it?

    Read the article

  • C - Complicated pointer declarations - help understanding

    - by Emmel
    In my burgeoning new self-education in the C language, I've come across a set of declarations that I do not understand how to read. I'd love for someone to break these down. I'll explain at the bottom where I got these examples from. 1. char (*(*x())[])() "x: function returning pointer to array[] of pointer to function returning char" - huh? 2. char (*(*x[3])())[5] "x: array[3] of pointer to function returning pointer to array[5] of char" - come again? 3. char **argv This I understand. "Pointer to pointer to char." But what I don't understand is -- what's the use case for a pointer to a pointer? Follow-up question: does anyone every use declarations this complex or is this just academic fun on the part of the authors of the examples I got this from? These examples are from section 5.12 of the K&R book. This is the first time I'm genuinely stumped by an explanation, in an otherwise well-written classic. Thanks.

    Read the article

  • Java declarations (ordering)

    - by incrediman
    In Java, what's generally the most accepted way to organize a class in terms of the order in which declared data members and methods should be listed in the class file, keeping in mind the following and anything else you can think of for each one: its visibility whether it's a constructor, method, or member if it's a method, does it overload, or override other method(s)?

    Read the article

  • Global qualification in a class declarations class-head

    - by gf
    We found something similar to the following (don't ask ...): namespace N { struct A { struct B; }; } struct A { struct B; }; using namespace N; struct ::A::B {}; // <- point of interest Interestingly, this compiles fine with VS2005, icc 11.1 and Comeau (online), but fails with GCC: global qualification of class name is invalid before '{' token From C++03, Annex A, it seems to me like GCC is right: the class-head can consist of nested-name-specifier and identifier nested-name-specifier can't begin with a global qualification (::) obviously, neither can identifier ... or am i overlooking something?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >