Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Compile time error - 'int8_t' : redefinition; different basic types

Compile time error - 'int8_t' : redefinition; different basic types

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++workspace
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gmallax
    wrote on last edited by
    #1

    I am working on transcoding using ffmpeg.For that,i have one class decoder for decoding purpose.That file name is video_decoder.h. Inside this file,im using the ffmpeg header files as extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> }; And,Im using the functions of this decoder class in my existing class say FileWriter.This file name is Video_Writer.h. so,i have included video_decoder.h in video_writer.cpp file.And ofcourse,video_writer.h also there.The problem starts here. Inside video_writer.h the variable type int8_t is defined in <lib_mp4v2\mpeg4ip_win32.h>. Also,Inside video_decoder.h the same variable type int8_t is defined in stdint.h. So,the compile time error is coming as e:\workspace\build_recorder_plugins.root\build_recorder_plugins\include\stdint.h(82) : error C2371: 'int8_t' : redefinition; different basic types e:\workspace\build_recorder_plugins.root\build_recorder_plugins\_build\include\lib_mp4v2\mpeg4ip_win32.h(52) : see declaration of 'int8_t' Pls help me to solve this..

    A 1 Reply Last reply
    0
    • G gmallax

      I am working on transcoding using ffmpeg.For that,i have one class decoder for decoding purpose.That file name is video_decoder.h. Inside this file,im using the ffmpeg header files as extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> }; And,Im using the functions of this decoder class in my existing class say FileWriter.This file name is Video_Writer.h. so,i have included video_decoder.h in video_writer.cpp file.And ofcourse,video_writer.h also there.The problem starts here. Inside video_writer.h the variable type int8_t is defined in <lib_mp4v2\mpeg4ip_win32.h>. Also,Inside video_decoder.h the same variable type int8_t is defined in stdint.h. So,the compile time error is coming as e:\workspace\build_recorder_plugins.root\build_recorder_plugins\include\stdint.h(82) : error C2371: 'int8_t' : redefinition; different basic types e:\workspace\build_recorder_plugins.root\build_recorder_plugins\_build\include\lib_mp4v2\mpeg4ip_win32.h(52) : see declaration of 'int8_t' Pls help me to solve this..

      A Offline
      A Offline
      Aescleal
      wrote on last edited by
      #2

      You've got a couple of choices... The first one is to work out if the types are compatible and if they are just use one of the definitions (presumably the one from stdint.h). If you can't do that then isolate the includes from each other behind interfaces. This might not be a bad idea as you won't be using the third party libraries directly and if you ever need to swap them out you can do it far easier. Have a search for the facade pattern online, that's the sort of thing (or pair of things) you need here. Cheers, Ash

      G 1 Reply Last reply
      0
      • A Aescleal

        You've got a couple of choices... The first one is to work out if the types are compatible and if they are just use one of the definitions (presumably the one from stdint.h). If you can't do that then isolate the includes from each other behind interfaces. This might not be a bad idea as you won't be using the third party libraries directly and if you ever need to swap them out you can do it far easier. Have a search for the facade pattern online, that's the sort of thing (or pair of things) you need here. Cheers, Ash

        G Offline
        G Offline
        gmallax
        wrote on last edited by
        #3

        Facade pattern can be used in same namespace..am i right?here,Video_writer.h and video_decoder.h are in different namespaces.how can i solve?Is facade pattern useful in this situation?

        A 1 Reply Last reply
        0
        • G gmallax

          Facade pattern can be used in same namespace..am i right?here,Video_writer.h and video_decoder.h are in different namespaces.how can i solve?Is facade pattern useful in this situation?

          A Offline
          A Offline
          Aescleal
          wrote on last edited by
          #4

          The first thing to do is eliminate any usage of those two libraries in the interfaces of your classes. Then make sure you only depend on one of the libraries in the implementation of each class. This provides the facade behind which it doesn't matter how int8_t is defined. So hide the video stream format stuff behind one class, your decoder behind another:

          video_decoder ---> libavdecoder
          |
          |
          |
          \--> video_format ---> libavformat

          ---> means "depends on" No single implementation file needs to include both avdecoder.h and avformat.h. Anyway, the point is this lot will work however you package your classes, whether in a namsepaces or not. It doesn't matter. Also, as a couple of general points: - don't stick class implementations in header files - only include header files that contain types that are used in the interface of a class in a header file This reduces the sort of problems you're having no end. Cheers, Ash

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups